Sort By Exact Key MatchΒΆ

Example

>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.countries import CreateThesaurus, SortByExactKeyMatch
>>> # Redirect stderr to capture output
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Create thesaurus
>>> CreateThesaurus(root_directory="example/", quiet=True).run()
>>> # Sorts thesaurus by key match
>>> (
...     SortByExactKeyMatch()
...     #
...     # THESAURUS:
...     .having_pattern("China")
...     .having_case_sensitive(False)
...     .having_regex_flags(0)
...     .having_regex_search(False)
...     #
...     # DATABASE:
...     .where_root_directory_is("example/")
...     #
...     .run()
... )
>>> # Capture and print stderr output
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)
Reducing thesaurus keys
  File : example/thesaurus/countries.the.txt
  Keys reduced from 24 to 24
  Keys reduction completed successfully

Sorting thesaurus file by exact key match
     File : example/thesaurus/countries.the.txt
  Pattern : China
  1 matching keys found
  Thesaurus sorting by exact key match completed successfully

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

    China
      Cheung Kong Graduate School of Business, and Institute of Internet Financ...
    Australia
      Centre for Law, Markets & Regulation, UNSW Australia, Australia; Charles ...
    Belgium
      Brussels, Belgium
    Brunei Darussalam
      Universiti Brunei Darussalam, School of Business and Economics, Jln Tungk...
    Denmark
      Copenhagen Business School, Department of IT Management, Howitzvej 60, Fr...
    France
      SKEMA Business School, Lille, France; University of Lille Nord de France,...
    Germany
      CESifo, Poschingerstr. 5, Munich, 81679, Germany; Chair of e-Finance, Goe...
    Ghana
      University of the Free State and University of Ghana Business School, Uni...