Sort By Exact Key MatchΒΆ

Example

>>> # Command line interface
>>> # python3 -m techminer2.thesaurus.descriptors.sort.sort_by_exact_key_match BLOCKCHAIN BLOCK_CHAIN

Example

>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.descriptors import CreateThesaurus, SortByExactKeyMatch
>>> # 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 = (
...     SortByExactKeyMatch()
...     .having_pattern("BLOCKCHAIN")
...     .having_case_sensitive(False)
...     .having_regex_flags(0)
...     .having_regex_search(False)
...     .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 exact key match
     File : example/thesaurus/descriptors.the.txt
  Pattern : BLOCKCHAIN
  1 matching keys found
  Thesaurus sorting by exact key match completed successfully

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

    BLOCKCHAIN
      BLOCKCHAIN; BLOCKCHAINS
    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
    A_CASE_STUDY
      A_CASE_STUDY
    A_CHALLENGE
      A_CHALLENGE