Python PyEnchant:使用个人单词列表检查文本块的拼写

Python PyEnchant:使用个人单词列表检查文本块的拼写,python,spell-checking,pyenchant,Python,Spell Checking,Pyenchant,因此,除了语言词典外,PyEnchant还允许您定义拼写正确的单词的个人单词列表: d2 = enchant.DictWithPWL("en_US","mywords.txt") from enchant import DictWithPWL from enchant.checker import SpellChecker my_dict = DictWithPWL("en_US", "mywords.txt") my_checker = SpellChecker(my_dict) my_

因此,除了语言词典外,PyEnchant还允许您定义拼写正确的单词的个人单词列表:

d2 = enchant.DictWithPWL("en_US","mywords.txt")
from enchant import DictWithPWL
from enchant.checker import SpellChecker

my_dict = DictWithPWL("en_US", "mywords.txt")
my_checker = SpellChecker(my_dict)

my_checker.set_text("This is sme sample txt with erors.")
for error in my_checker:
    print "ERROR:", error.word
但是,生成的
d2
检查器属于
Dict
类,只能用于检查单个单词,例如:

>>> d.check("Hello")
True

拼写检查器
类允许对文本块进行拼写检查。然而,我似乎无法找到如何像使用
Dict
那样指定个人单词列表。这不是受支持的功能吗?我想用en_US加上我的个人单词表来拼写一段文字。有什么想法吗?

拼写检查器初始值设定项的第一个参数可以是语言名称或enchant字典:

d2 = enchant.DictWithPWL("en_US","mywords.txt")
from enchant import DictWithPWL
from enchant.checker import SpellChecker

my_dict = DictWithPWL("en_US", "mywords.txt")
my_checker = SpellChecker(my_dict)

my_checker.set_text("This is sme sample txt with erors.")
for error in my_checker:
    print "ERROR:", error.word

文档对此并不清楚,但是:)

指定个人单词列表到底是什么意思?@aj8uppal:意思是文件
mywords.txt
包含我想要拼写检查的单词列表。更多信息请点击此处: