pyaspeller (Python Yandex Speller) is a search tool typos in the text, files and websites. Used API Yandex.Speller.
$ pyaspeller "testt reques"
{u'code': 1,
u'col': 0,
u'len': 5,
u'pos': 0,
u'row': 0,
u's': [u'test'],
u'word': u'testt'}
{u'code': 1,
u'col': 6,
u'len': 6,
u'pos': 6,
u'row': 0,
u's': [u'request'],
u'word': u'reques'}
You could use class Word
for single word queries:
>>> from pyaspeller import Word
>>> check = Word('tesst')
>>> check.correct
False
>>> check.variants
[u'test']
>>> check.spellsafe
u'test'
For whole text you could use:
>>> from pyaspeller import YandexSpeller
>>> speller = YandexSpeller()
>>> text = 'В суббботу утромь.'
>>> changes = {change['word']: change['s'][0] for change in speller.spell(text)}
>>> for word, suggestion in changes.items():
... text = text.replace(word, suggestion)
>>> text
'В субботу утром.'
To install pyaspeller
, simply do:
$ pip install pyaspeller
$ pyaspeller --help
speller has some restrictions