Sort by Word LengthΒΆ
Example
>>> # TEST PREPARATION
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.user import InitializeThesaurus, SortByWordLength
>>> # 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 = (
... SortByWordLength(use_colorama=False)
... .with_thesaurus_file("demo.the.txt")
... .having_keys_ordered_by("alphabetical")
... .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 = StringIO()
>>> print(output)
Sorting thesaurus by word length...
File : examples/fintech/data/thesaurus/demo.the.txt
Sorting process completed successfully
Printing thesaurus header
File : examples/fintech/data/thesaurus/demo.the.txt
COMPETITION (ECONOMICS)
COMPETITION (ECONOMICS)
FINANCIAL_TECHNOLOGY (FINTECH)
FINANCIAL_TECHNOLOGY (FINTECH)
A_WIDE_RANGING_RECONCEPTUALIZATION
A_WIDE_RANGING_RECONCEPTUALIZATION
NETWORKS (CIRCUITS)
NETWORKS (CIRCUITS)
THE_RECONCEPTUALIZATION
THE_RECONCEPTUALIZATION
CLASSIFICATION (OF_INFORMATION)
CLASSIFICATION (OF_INFORMATION)
EXPLORE_INTERRELATIONSHIPS
EXPLORE_INTERRELATIONSHIPS
A_DISINTERMEDIATION_FORCE
A_DISINTERMEDIATION_FORCE