British to American SpellingΒΆ

Example

>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.user import BritishToAmericanSpelling, InitializeThesaurus
>>> # Redirecting stderr to avoid messages during doctests
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Reset the thesaurus to initial state
>>> InitializeThesaurus(thesaurus_file="demo.the.txt", field="raw_descriptors",
...     root_directory="examples/fintech/", quiet=True).run()
>>> # Creates, configures, an run the translator
>>> translator = (
...     BritishToAmericanSpelling(tqdm_disable=True, use_colorama=False)
...     .with_thesaurus_file("demo.the.txt")
...     .where_root_directory_is("examples/fintech/")
... )
>>> translator.run()
>>> # Capture and print stderr output to test the code using doctest
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output) 
Converting British to American English...
  File : examples/fintech/data/thesaurus/demo.the.txt
  10 replacements made successfully
  Translation process completed successfully

Printing thesaurus header
  File : examples/fintech/data/thesaurus/demo.the.txt

    ANALOG_PROCESSES
      ANALOGUE_PROCESSES
    ANALYZE
      ANALYSE
    BEHAVIORAL_ECONOMICS
      BEHAVIOURAL_ECONOMICS
    ENTREPRENEURIAL_ENDEAVORS
      ENTREPRENEURIAL_ENDEAVOURS
    FAVOR
      FAVOUR
    HARMONIZE_TECHNOLOGICAL_ADVANCEMENTS
      HARMONISE_TECHNOLOGICAL_ADVANCEMENTS
    INSTILL_CULTURE_CHANGE
      INSTIL_CULTURE_CHANGE
    INTERNATIONAL_DEVELOPMENT_ORGANIZATIONS
      INTERNATIONAL_DEVELOPMENT_ORGANISATIONS