Sort by AlphabetΒΆ
Example
>>> # TEST PREPARATION
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.user import InitializeThesaurus, SortByAlphabet
>>> # 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
>>> (
... SortByAlphabet(use_colorama=False)
... .with_thesaurus_file("demo.the.txt")
... .having_keys_ordered_by("alphabetical")
... .where_root_directory_is("examples/fintech/")
... .run()
... )
>>> # Capture and print stderr output to test the code using doctest
>>> output = sys.stderr.getvalue()
>>> sys.stderr = StringIO()
>>> print(output)
Sorting thesaurus alphabetically...
File : examples/fintech/data/thesaurus/demo.the.txt
Sorting process completed successfully
Printing thesaurus header
File : examples/fintech/data/thesaurus/demo.the.txt
ABOUT_ONE_THIRD
ABOUT_ONE_THIRD
ACADEMIA
ACADEMIA
ACADEMICS
ACADEMICS
ACADEMIC_OBSERVERS
ACADEMIC_OBSERVERS
ACADEMIC_RESEARCH
ACADEMIC_RESEARCH
ACCELERATE_ACCESS
ACCELERATE_ACCESS
ACCESS
ACCESS
ACCESS_LOANS
ACCESS_LOANS