Sort by Starts With Match

Example

>>> # TEST PREPARATION
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.organizations import InitializeThesaurus, SortByStartsWithMatch
>>> # Redirecting stderr to avoid messages
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Create thesaurus
>>> InitializeThesaurus(root_directory="examples/fintech/", quiet=True).run()
>>> # Create and run the sorter
>>> sorter = (
...     SortByStartsWithMatch(use_colorama=False)
...     #
...     # THESAURUS:
...     .having_pattern("Univ")
...     #
...     # DATABASE:
...     .where_root_directory_is("examples/fintech/")
... )
>>> sorter.run()
>>> # Capture and print stderr output
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)
Sorting thesaurus by startswith match...
     File : examples/fintech/data/thesaurus/organizations.the.txt
  Pattern : Univ
  26 matching keys found
  Sorting process completed successfully

Printing thesaurus header
  File : examples/fintech/data/thesaurus/organizations.the.txt

    Univ Brunei Darussalam (BRN)
      Universiti Brunei Darussalam, School of Business and Economics, Jln Tungk...
    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 ...