我想纠正法语文本中的拼写错误,看来spacy是最准确、最快捷的方法,但它很复杂, 我试过用textblob,但没能用法语单词
它在英语中非常好用,但是当我试图用法语做同样的事情时,我得到了同样的拼写错误的单词
#english words
from textblob import TextBlob
misspelled=["hapenning", "mornin", "windoow", "jaket"]
[str(TextBlob(word).correct()) for word in misspelled]
#french words
misspelled2=["resaissir", "matinnée", "plonbier", "tecnicien"]
[str(TextBlob(word).correct()) for word in misspelled2]
我明白了:
英语: [“发生”,“早晨”,“窗户”,“夹克”]
法语: ['resassir'、'matinnée'、'plonbier'、'tecnicien']
textblob
仅支持英语。这就是为什么它返回法语单词的原样,没有任何更正。如果要将其用于法语,则需要安装textblob-fr
。但根据其官方存储库here,textblob-fr
不支持拼写检查。在此外,spaCy的语言模型不支持拼写检查。有一个解决方案是使用
spacy_hunspell
包装hunspell
(LibreOffice和Mozilla Firefox的拼写检查器),但它也不支持法语。在所以,我的建议是使用
pyspellchecker
,它支持英语、法语、德语、西班牙语和葡萄牙语。。。它可以通过pip
轻松安装,如下所示:英语
以下是如何在英语中使用它:
^{pr2}$法语
这里是如何使用它与法语。。。它与英语中指定
langauge=fr
完全相同:相关问题 更多 >
编程相关推荐