Sort By Match¶
Example
>>> # TEST PREPARATION
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.organizations import InitializeThesaurus, SortByMatch
>>> # 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 = (
... SortByMatch(use_colorama=False)
... #
... # THESAURUS:
... .having_pattern("Sch")
... .having_case_sensitive(False)
... .having_regex_flags(0)
... .having_regex_search(False)
... #
... # 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 match...
File : examples/fintech/data/thesaurus/organizations.the.txt
Pattern : Sch
Case sensitive : False
Regex Flags : 0
Regex Search : False
12 matching keys found
Sorting process completed successfully
Printing thesaurus header
File : examples/fintech/data/thesaurus/organizations.the.txt
[UKN] CESifo, Poschingerstr. 5, Munich, 81679, Germany (DEU)
CESifo, Poschingerstr. 5, Munich, 81679, Germany
[UKN] Hochschule für Wirtschaft Fribourg, Switzerland (CHE)
Hochschule für Wirtschaft Fribourg, Switzerland
Columbia Grad Sch of Bus (USA)
Columbia Graduate School of Business, United States
Copenhagen Bus Sch (DNK)
Copenhagen Business School, Department of IT Management, Howitzvej 60, Fr...
Harvard Law Sch (USA)
Harvard Law School, United States
Henley Bus Sch (GBR)
Henley Business School, United Kingdom
Kingston Bus Sch (GBR)
Kingston Business School, Department of Accounting, Finance and Informati...
London Sch of Econ (GBR)
London School of Economics, United Kingdom