Spell CheckΒΆ
Example
>>> # TEST PREPARATION
>>> import sys
>>> from io import StringIO
>>> from techminer2.thesaurus.user import InitializeThesaurus, SpellCheck
>>> # 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 spell checker
>>> (
... SpellCheck(use_colorama=False)
... .with_thesaurus_file("demo.the.txt")
... .having_maximum_occurrence(3)
... .where_root_directory_is("examples/fintech/")
... .run()
... )
>>> # Capture and print stderr output to test the code using doctest
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)
Spell checking thesaurus keys...
File : examples/fintech/data/thesaurus/demo.the.txt
Potential misspelled words (59):
- affordance
- affordances
- backoffice
- behavioural
- bitcoin
- blockchain
- burdencapital
- centricity
- crowdfunding
- crowdinvesting
...
Matching keys found : 71
Spell checking process completed successfully
Printing thesaurus header
File : examples/fintech/data/thesaurus/demo.the.txt
A_BEHAVIOURAL_PERSPECTIVE
A_BEHAVIOURAL_PERSPECTIVE
A_BLOCKCHAIN_IMPLEMENTATION_STUDY
A_BLOCKCHAIN_IMPLEMENTATION_STUDY
A_HYBRID_MCDM_MODEL
A_HYBRID_MCDM_MODEL
A_MULTI_LEVEL_ANALYSIS
A_MULTI_LEVEL_ANALYSIS
A_WIDE_RANGING_RECONCEPTUALIZATION
A_WIDE_RANGING_RECONCEPTUALIZATION
A_YOUTH_MICROLOAN_STARTUP
A_YOUTH_MICROLOAN_STARTUP
AFFORDANCE_ACTUALIZATION
AFFORDANCE_ACTUALIZATION
AFFORDANCES
AFFORDANCES
>>> # Restaring the stderr
>>> sys.stderr = StringIO()
>>> # Creates, configures, an run the spell checker
>>> SpellCheck(
... thesaurus_file="demo.the.txt",
... maximum_occurrence=3,
... root_directory="examples/fintech/",
... use_colorama=False,
... ).run()
>>> # Capture and print stderr output
>>> output = sys.stderr.getvalue()
>>> sys.stderr = original_stderr
>>> print(output)
Spell checking thesaurus keys...
File : examples/fintech/data/thesaurus/demo.the.txt
Potential misspelled words (59):
- affordance
- affordances
- backoffice
- behavioural
- bitcoin
- blockchain
- burdencapital
- centricity
- crowdfunding
- crowdinvesting
...
Matching keys found : 71
Spell checking process completed successfully
Printing thesaurus header
File : examples/fintech/data/thesaurus/demo.the.txt
A_BEHAVIOURAL_PERSPECTIVE
A_BEHAVIOURAL_PERSPECTIVE
A_BLOCKCHAIN_IMPLEMENTATION_STUDY
A_BLOCKCHAIN_IMPLEMENTATION_STUDY
A_HYBRID_MCDM_MODEL
A_HYBRID_MCDM_MODEL
A_MULTI_LEVEL_ANALYSIS
A_MULTI_LEVEL_ANALYSIS
A_WIDE_RANGING_RECONCEPTUALIZATION
A_WIDE_RANGING_RECONCEPTUALIZATION
A_YOUTH_MICROLOAN_STARTUP
A_YOUTH_MICROLOAN_STARTUP
AFFORDANCE_ACTUALIZATION
AFFORDANCE_ACTUALIZATION
AFFORDANCES
AFFORDANCES