Sort by Fuzzy Key Match¶
Example
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.organizations import CreateThesaurus, SortByFuzzyKeyMatch
>>> # 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 = (
... SortByFuzzyKeyMatch()
... #
... # THESAURUS:
... .having_pattern("Texas")
... .having_match_threshold(70)
... #
... # 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 by fuzzy match
File : example/thesaurus/organizations.the.txt
Keys like : Texas
Match thresold : 70
3 matching keys found
Thesaurus sorting completed successfully
Printing thesaurus header
File : example/thesaurus/organizations.the.txt
Texas AandM Univ Sch of Law (USA)
Texas AandM University School of Law, United States
Univ of North Texas (USA)
Department of Information Technology & Decision Sciences, University of N...
Univ of Texas at Austin (USA)
McCombs School of Business, University of Texas at Austin, United States
Anhui Univ of Finan and Econ (CHN)
School of Finance, Anhui University of Finance and Economics, Bengbu, 233...
Baekseok Univ (KOR)
Division of Tourism, Baekseok University, South Korea
Baewha Women’s Univ (KOR)
Department of Information Security, Baewha Women’s University, Seoul, Sou...
Baylor Univ (USA)
Baylor University, United States; Hankamer School of Business, Baylor Uni...
Beihang Univ (CHN)
School of Economics and Management, Beihang University, China