首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用textblob或spacy更正法语中的拼写

使用textblob或spacy更正法语中的拼写
EN

Stack Overflow用户
提问于 2019-11-04 21:47:45
回答 1查看 4.1K关注 0票数 3

我想纠正法语文本中拼写错误的单词,似乎spacy是最准确和最快的软件包,但它太复杂了,我尝试使用textblob,但我不能用法语单词来纠正

它在英语中工作得很好,但当我尝试用法语做同样的事情时,我得到了同样的拼写错误的单词

代码语言:javascript
运行
复制
#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”

EN

回答 1

Stack Overflow用户

发布于 2019-11-08 04:28:23

textblob仅支持英语。这就是为什么它返回法语单词,因为它们没有任何更正。如果你想在法语中使用它,那么你需要安装textblob-fr。但根据其官方存储库heretextblob-fr不支持拼写检查。

此外,spaCy不支持对其语言模型进行拼写检查。有一个解决方法是使用包装hunspell ( LibreOffice和Mozilla Firefox的拼写检查器)的spacy_hunspell,但它也不支持法语。

所以,我的建议是使用支持英语、法语、德语、西班牙语和葡萄牙语的pyspellchecker……它可以很容易地通过pip安装,如下所示:

代码语言:javascript
运行
复制
pip install pyspellchecker

英语

以下是如何在英语中使用它:

代码语言:javascript
运行
复制
>>> 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的英语完全相同

代码语言:javascript
运行
复制
>>> 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
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58694762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档