Sort by Starts With Key Match

Example

>>> # TEST PREPARATION
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.organizations import CreateThesaurus, SortByStartsWithKeyMatch
>>> # Redirecting stderr to avoid messages
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Create thesaurus
>>> CreateThesaurus(root_directory="example/", quiet=True).run()
>>> # Create and run the sorter
>>> sorter = (
...     SortByStartsWithKeyMatch()
...     #
...     # THESAURUS:
...     .having_pattern("Univ")
...     #
...     # DATABASE:
...     .where_root_directory_is("example/")
... )
>>> sorter.run()
>>> # Capture and print stderr output
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)
Sorting thesaurus file by key match
     File : example/thesaurus/organizations.the.txt
  Pattern : Univ
  25 matching keys found
  Thesaurus sorting by key match completed successfully

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

    Univ di Padova (ITA)
      Università di Padova, Italy
    Univ Gadjah Mada (IDN)
      Department of Management, Faculty of Economics and Business, Universitas ...
    Univ Koblenz-Landau (DEU)
      Institute for Software Technology IST, Universität Koblenz-Landau, Koblen...
    Univ of Augsburg (DEU)
      FIM Research Center, University of Augsburg, Augsburg, 86135, Germany
    Univ of Bremen (DEU)
      Faculty of Business Studies and Economics, University of Bremen, Wilhelm-...
    Univ of Chicago (USA)
      University of Chicago, United States
    Univ of Delaware (USA)
      Lerner College of Business and Economics, University of Delaware, United ...
    Univ of Groningen (NLD)
      Faculty of Economics and Business, University of Groningen, Nettelbosje 2...