Sort by Word Key MatchΒΆ

Example

>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.descriptors import CreateThesaurus, SortByWordKeyMatch
>>> # Redirecting stderr to avoid messages
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Create the thesaurus
>>> CreateThesaurus(root_directory="example/", quiet=True).run()
>>> # Configure and run the sorter
>>> sorter = (
...     SortByWordKeyMatch()
...     .having_pattern("CREDIT")
...     .where_root_directory_is("example/")
... )
>>> sorter.run()
>>> # Capture and print stderr output
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)
Reducing thesaurus keys
  File : example/thesaurus/descriptors.the.txt
  Keys reduced from 1729 to 1729
  Keys reduction completed successfully

Sorting thesaurus file by word match
  File : example/thesaurus/descriptors.the.txt
  Word : CREDIT
  4 matching keys found
  Thesaurus sorting by word match completed successfully

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

    ALTERNATIVE_CREDIT_SCORES
      ALTERNATIVE_CREDIT_SCORES
    CREDIT_ACCESS
      CREDIT_ACCESS
    CREDIT_COOPERATIVES
      CREDIT_COOPERATIVES
    LOWER_PRICED_CREDIT
      LOWER_PRICED_CREDIT
    A_A_THEORY
      A_A_THEORY
    A_BASIC_RANDOM_SAMPLING_STRATEGY
      A_BASIC_RANDOM_SAMPLING_STRATEGY
    A_BEHAVIOURAL_PERSPECTIVE
      A_BEHAVIOURAL_PERSPECTIVE
    A_BETTER_UNDERSTANDING
      A_BETTER_UNDERSTANDING