Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions enchant2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,39 @@ test:
environment:
contents:
packages:
- python3
- enchant2-dev
- hunspell-dev
- hunspell-dictionaries-all
- py3-pip
- python3
pipeline:
- runs: |
pip install pyenchant
# this fails without the enchant libraries installed
python -c "import enchant"
pip3 install spello pyenchant
- runs: |
python -c '
import enchant
from spello.model import SpellCorrectionModel

d = enchant.Dict("en_US")

word = "recieve"
assert not d.check(word), f"{word} should be misspelled"
suggestions = d.suggest(word)
expected_suggestions = ["receive", "relieve", "reverie"]
assert set(expected_suggestions).issubset(set(suggestions)), f"Suggestions for {word} are incorrect. Got: {suggestions}"

sp = SpellCorrectionModel(language="en")
sp.train(["I want to play cricket", "this is a text corpus"])

sentence = "i wnt to plai kricket"
correction = sp.spell_correct(sentence)
expected_correction = {
"original_text": "i wnt to plai kricket",
"spell_corrected_text": "i want to play cricket",
"correction_dict": {
"wnt": "want",
"plai": "play",
"kricket": "cricket"
}
}
assert correction == expected_correction, f"Correction for {sentence} is incorrect. Expected: {expected_correction}, but got: {correction}"'