File tree Expand file tree Collapse file tree 1 file changed +33
-4
lines changed
Expand file tree Collapse file tree 1 file changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,39 @@ test:
5959 environment :
6060 contents :
6161 packages :
62- - python3
62+ - enchant2-dev
63+ - hunspell-dev
64+ - hunspell-dictionaries-all
6365 - py3-pip
66+ - python3
6467 pipeline :
6568 - runs : |
66- pip install pyenchant
67- # this fails without the enchant libraries installed
68- python -c "import enchant"
69+ pip3 install spello pyenchant
70+ - runs : |
71+ python -c '
72+ import enchant
73+ from spello.model import SpellCorrectionModel
74+
75+ d = enchant.Dict("en_US")
76+
77+ word = "recieve"
78+ assert not d.check(word), f"{word} should be misspelled"
79+ suggestions = d.suggest(word)
80+ expected_suggestions = ["receive", "relieve", "reverie"]
81+ assert set(expected_suggestions).issubset(set(suggestions)), f"Suggestions for {word} are incorrect. Got: {suggestions}"
82+
83+ sp = SpellCorrectionModel(language="en")
84+ sp.train(["I want to play cricket", "this is a text corpus"])
85+
86+ sentence = "i wnt to plai kricket"
87+ correction = sp.spell_correct(sentence)
88+ expected_correction = {
89+ "original_text": "i wnt to plai kricket",
90+ "spell_corrected_text": "i want to play cricket",
91+ "correction_dict": {
92+ "wnt": "want",
93+ "plai": "play",
94+ "kricket": "cricket"
95+ }
96+ }
97+ assert correction == expected_correction, f"Correction for {sentence} is incorrect. Expected: {expected_correction}, but got: {correction}"'
You can’t perform that action at this time.
0 commit comments