python - 使用 pyenchant 时出错 : enchant_dict_check: assertion `g_utf8_validate(word, len, NULL)' failed

标签 python dictionary spell-checking pyenchant

我正在尝试根据英语词典检查标签列表。我正在使用 pyenchant 并且我不断收到错误。读到一个“?”后好像出错了。我尝试使用字符串库和以下代码删除所有标点符号:

for punc in string.punctuation:
    title = title.replace(punc,'')

但是这个 char 看起来像什么?正在扔字典。

代码片段:

if word not in stopwords.words('english'):
    print word, "=", d.check(word) 
    if d.check(word):       
        tags.append(word.lower())

响应:

Learning = True
Lens = True
Children = True
Pumkincom = False
Pumkin = False

** (process:49042): CRITICAL **: enchant_dict_check: assertion `g_utf8_validate(word, len, NULL)' failed
     ? =

我正在使用 Python 2.7.3 和 pyenchant-1.6.5-py2.7

编辑:我想我通过检查是否 len(word)==1 解决了这个问题,但我想知道为什么会这样。

最佳答案

我之前遇到过这个问题,但这是因为文本中存在非英文字母 我建议你确保这个词只包含英文字母

关于python - 使用 pyenchant 时出错 : enchant_dict_check: assertion `g_utf8_validate(word, len, NULL)' failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13505812/

相关文章:

python - 使用 Python 将多个关系表转换为嵌套的 JSON 格式

python - 如何使用 SpaCy 从句子列表中获取名词短语

python - 从现有词典创建频率词典

python - 动态填充字典

c# - 拼写检查仅替换文本框中的第一个单词

.net - 带有 SpellCheck.IsEnabled ="True"的 WPF 文本框 - 没有发生拼写检查?

java - 安卓字验证

python - 无法在 Seaborn stripplot 中使用 'x' 和 '+' 标记

python - 替换主词典中的用户输入列表元素?

python - 按间隔合并两个 Pandas 数据帧