Sort by Last WordΒΆ
Example
>>> # TEST PREPARATION
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.user import InitializeThesaurus, SortByLastWords
>>> # Redirecting stderr to avoid messages during doctests
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Reset the thesaurus to initial state
>>> InitializeThesaurus(thesaurus_file="demo.the.txt", field="raw_descriptors",
... root_directory="examples/fintech/", quiet=True).run()
>>> # Creates, configures, an run the sorter
>>> sorter = (
... SortByLastWords(use_colorama=False)
... .with_thesaurus_file("demo.the.txt")
... .where_root_directory_is("examples/fintech/")
... )
>>> sorter.run()
>>> # Capture and print stderr output to test the code using doctest
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)
Sorting thesaurus by common last words...
File : examples/fintech/data/thesaurus/demo.the.txt
17 matching keys found
Sorting process completed successfully
Printing thesaurus header
File : examples/fintech/data/thesaurus/demo.the.txt
AGRICULTURE_PLAYS
AGRICULTURE_PLAYS
CHINA_EASTERN
CHINA_EASTERN
CONTINUANCE_INTENTION_DIFFERS
CONTINUANCE_INTENTION_DIFFERS
DIGITAL_FINANCE_ENCOMPASSES
DIGITAL_FINANCE_ENCOMPASSES
ENTREPRENEURIAL_ENDEAVOURS
ENTREPRENEURIAL_ENDEAVOURS
FOUR_SPECIFIC_INCREASES
FOUR_SPECIFIC_INCREASES
INNOVATIONS_EXACERBATE
INNOVATIONS_EXACERBATE
LENDINGCLUB_LOANS_INCREASES
LENDINGCLUB_LOANS_INCREASES