Sort by OccurrencesΒΆ
Example
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.descriptors import InitializeThesaurus, SortByOccurrences
>>> # Redirecting stderr to avoid messages
>>> original_stderr = sys.stderr
>>> sys.stderr = StringIO()
>>> # Create the thesaurus
>>> InitializeThesaurus(root_directory="examples/fintech/", quiet=True).run()
>>> # Configure and run the sorter
>>> sorter = (
... SortByOccurrences(use_colorama=False)
... .where_root_directory_is("examples/fintech/")
... )
>>> sorter.run()
>>> # Capture and print stderr output
>>> output = sys.stderr.getvalue()
>>> sys.stderr = StringIO()
>>> print(output)
Sorting thesaurus by occurrences...
File : examples/fintech/data/thesaurus/descriptors.the.txt
Sorting process completed successfully
Printing thesaurus header
File : examples/fintech/data/thesaurus/descriptors.the.txt
FINTECH
FINTECH; FINTECHS
FINANCE
FINANCE
TECHNOLOGIES
TECHNOLOGIES; TECHNOLOGY
INNOVATION
INNOVATION; INNOVATIONS
FINANCIAL_SERVICE
FINANCIAL_SERVICE; FINANCIAL_SERVICES
FINANCIAL_TECHNOLOGIES
FINANCIAL_TECHNOLOGIES; FINANCIAL_TECHNOLOGY
BANKS
BANKS
THE_DEVELOPMENT
THE_DEVELOPMENT; THE_DEVELOPMENTS