Sort by Initial WordsΒΆ

Example

>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.descriptors import InitializeThesaurus, SortByInitialWords
>>> # Redirecting stderr to avoid messages
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Create the thesaurus
>>> InitializeThesaurus(root_directory="examples/fintech/", quiet=True).run()
>>> # Configure and run the sorter
>>> sorter = (
...     SortByInitialWords(use_colorama=False)
...     .where_root_directory_is("examples/fintech/")
... )
>>> sorter.run()
>>> # Capture and print stderr output
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)  
Sorting thesaurus by common initial words...
  File : examples/fintech/data/thesaurus/descriptors.the.txt
  214 matching keys found
  Sorting process completed successfully

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

    ACCELERATE_ACCESS
      ACCELERATE_ACCESS
    ACTIVE_CUSTOMERS
      ACTIVE_CUSTOMERS
    ACTIVE_FINTECH_SOLUTIONS
      ACTIVE_FINTECH_SOLUTIONS
    ACTIVE_POLICIES
      ACTIVE_POLICIES
    ADDITIONAL_DATA
      ADDITIONAL_DATA
    ADDITIONAL_USE
      ADDITIONAL_USE
    ADDRESSES_RISK
      ADDRESSES_RISK
    ADVANCED_ECONOMIES
      ADVANCED_ECONOMIES