我正在尝试根据英语词典检查标签列表。我正在使用 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/