在法语中使用textblob或spacy进行更正拼写

我想纠正法文中拼写错误的单词,看来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]

我明白了:

英语: [“正在发生”,“早晨”,“窗口”,“夹克”]

法语: ['resaissir','matinnée','plonbier','tecnicien']

shuiyezhu 回答:在法语中使用textblob或spacy进行更正拼写

textblob仅支持英语。这就是为什么它不做任何更正就返回法语单词的原因。如果要将其用于法语,则需要安装textblob-fr。但根据其官方存储库heretextblob-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

大家都在问