Replace WordΒΆ
Example
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.descriptors import InitializeThesaurus, ReplaceWord
>>> # Redirecting stderr to avoid messages
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Create thesaurus
>>> InitializeThesaurus(root_directory="examples/fintech/", quiet=True).run()
>>> # Configure and run the replacer
>>> replacer = (
... ReplaceWord(use_colorama=False)
... .having_word("FINTECH")
... .having_replacement("fintech")
... .where_root_directory_is("examples/fintech/")
... )
>>> replacer.run()
>>> # Capture and print stderr output
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)
Replacing word in keys...
File : ...h/data/thesaurus/descriptors.the.txt
Word : FINTECH
Replacement : fintech
93 replacements made successfully
Replacement process completed successfully
Printing thesaurus header
File : examples/fintech/data/thesaurus/descriptors.the.txt
A_EUROPEAN_OR_NATIONAL_fintech_MARKET
A_EUROPEAN_OR_NATIONAL_FINTECH_MARKET
A_fintech_COMPANY
A_FINTECH_COMPANY
A_fintech_ECOSYSTEM
A_FINTECH_ECOSYSTEM
A_NEW_fintech_INNOVATION_MAPPING_APPROACH
A_NEW_FINTECH_INNOVATION_MAPPING_APPROACH
A_THEORETICAL_DATA_DRIVEN_fintech_FRAMEWORK
A_THEORETICAL_DATA_DRIVEN_FINTECH_FRAMEWORK
ACTIVE_fintech_SOLUTIONS
ACTIVE_FINTECH_SOLUTIONS
ADOPTION_OF_fintech
ADOPTION_OF_FINTECH
ADOPTION_OF_fintech_SERVICES
ADOPTION_OF_FINTECH_SERVICES