Replace Ends With WordΒΆ

Example

>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.descriptors import CreateThesaurus, ReplaceEndsWithWord
>>> # 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 = (
...     ReplaceEndsWithWord()
...     .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 ending word in keys
         File : example/thesaurus/descriptors.the.txt
         Word : FINTECH
  Replacement : fintech
  10 replacements made successfully
  Word replacing completed successfully

Printing thesaurus header
  File : example/thesaurus/descriptors.the.txt

    CHARACTERIZE_fintech
      CHARACTERIZE_FINTECH
    EXPLORE_fintech
      EXPLORE_FINTECH
    fintech
      FINTECH; FINTECHS
    FRAME_fintech
      FRAME_FINTECH
    MORE_fintech
      MORE_FINTECH
    PROMPTPAY_fintech
      PROMPTPAY_FINTECH
    THAT_fintech
      THAT_FINTECH
    THE_TERM_fintech
      THE_TERM_FINTECH