textblob
仅支持英语。这就是为什么它不做任何更正就返回法语单词的原因。如果要将其用于法语,则需要安装textblob-fr
。但根据其官方存储库here,textblob-fr
不支持拼写检查。
除了spaCy之外,它的语言模型也不支持拼写检查。有一种使用spacy_hunspell
来包装hunspell
(LibreOffice和Mozilla Firefox的拼写检查器)的解决方法,但是它也不支持法语。
因此,我的建议是使用支持英语,法语,德语,西班牙语和葡萄牙语的pyspellchecker
...可以像这样通过pip
轻松安装:
pip install pyspellchecker
英语
以下是如何在英语中使用它:
>>> from spellchecker import SpellChecker
>>>
>>> spell = SpellChecker()
>>> misspelled = ["hapenning","mornin","windoow","jaket"]
>>> misspelled = spell.unknown(misspelled)
>>> for word in misspelled:
... print(word,spell.correction(word))
jaket jacket
windoow window
mornin morning
hapenning happening
法语
这里是如何在法语中使用它...与英语完全相同,指定了langauge=fr
:
>>> from spellchecker import SpellChecker
>>>
>>> spell = SpellChecker(language='fr')
>>> misspelled = ["resaissir","matinnée","plonbier","tecnicien"]
>>> misspelled = spell.unknown(misspelled)
>>> for word in misspelled:
... print(word,spell.correction(word))
plonbier plombier
matinnée matinée
tecnicien technicien
resaissir ressaisir
本文链接:https://www.f2er.com/3166266.html