Skip to content

Commit 1f5114d

Browse files
authored
Merge pull request #23708 from mamccorm/pyenchant-tests
Add additional tests
2 parents 7f705cd + 91b4fe5 commit 1f5114d

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

enchant2.yaml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff 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}"'

0 commit comments

Comments
 (0)