Replace Starts With WordΒΆ
Example
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.descriptors import CreateThesaurus, ReplaceStartsWithWord
>>> # Redirecting stderr to avoid messages
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Create thesaurus
>>> CreateThesaurus(root_directory="example/", quiet=True).run()
>>> # Configure and run the replacer
>>> replacer = (
... ReplaceStartsWithWord()
... .having_word("FINTECH")
... .having_replacement("fintech")
... .where_root_directory_is("example/")
... )
>>> replacer.run()
>>> # Capture and print stderr output
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)
Replacing starting word in keys
File : example/thesaurus/descriptors.the.txt
Word : FINTECH
Replacement : fintech
35 replacements made successfully
Word replacing completed successfully
Printing thesaurus header
File : example/thesaurus/descriptors.the.txt
fintech
FINTECH; FINTECHS
fintech_AND_FINANCIAL_INNOVATIONS
FINTECH_AND_FINANCIAL_INNOVATIONS
fintech_AND_REGTECH_:_IMPACT
FINTECH_AND_REGTECH_:_IMPACT
fintech_AND_SUSTAINABLE_DEVELOPMENT_:_EVIDENCE
FINTECH_AND_SUSTAINABLE_DEVELOPMENT_:_EVIDENCE
fintech_BANKING_INDUSTRY
FINTECH_BANKING_INDUSTRY
fintech_BASED_INNOVATION_DEVELOPMENT
FINTECH_BASED_INNOVATION_DEVELOPMENT
fintech_BASED_INNOVATIONS
FINTECH_BASED_INNOVATIONS; FINTECH_INNOVATION
fintech_CLUSTERS
FINTECH_CLUSTERS