Sort by Starts With Key Match

Example

>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.descriptors import CreateThesaurus, SortByStartsWithKeyMatch
>>> # 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 = (
...     SortByStartsWithKeyMatch()
...     .having_pattern("COMM")
...     .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 key match
     File : example/thesaurus/descriptors.the.txt
  Pattern : COMM
  3 matching keys found
  Thesaurus sorting by key match completed successfully

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

    COMMERCE
      COMMERCE
    COMMERCIAL_BANKS
      COMMERCIAL_BANKS
    COMMUNICATION_AND_INTERACTION
      COMMUNICATION_AND_INTERACTION
    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
    A_BLOCKCHAIN_IMPLEMENTATION_STUDY
      A_BLOCKCHAIN_IMPLEMENTATION_STUDY

techminer2.thesaurus.descriptors.sort.sort_by_starts_with_key_match.startswith(pattern)[source]