backend/app/search/services/spell_check.py

11 lines
226 B
Python
Raw Normal View History

2022-10-22 04:58:10 +03:00
import requests as r
2022-10-22 17:31:40 +03:00
from spellchecker import SpellChecker
2022-10-22 04:58:10 +03:00
2022-10-22 17:31:40 +03:00
speller = SpellChecker(language='ru')
2022-10-22 04:58:10 +03:00
def spell_check(word: str) -> str:
2022-10-22 17:31:40 +03:00
res = speller.correction(word)
if not len(res):
return word
return res