PyEnchant似乎对某些字母/数字组合怪异的行为:错误PyEnchant当某些字母/数字用来
>>> import enchant
>>> d=enchant.Dict("en_US")
>>> d.add("def")
>>> d.add("abc")
>>> d.suggest("P92")
** (python.exe:15036): CRITICAL **: enchant_is_all_caps: assertion `word && *word' failed
['ᾈ\t_us', 'Def', 'Abc']
并不是每一个字母/数字组合产生这个问题。更多示例如下:
>>> d.suggest("A92")
['Abc']
>>> d.suggest("92P")
** (python.exe:15036): CRITICAL **: enchant_is_all_caps: assertion `word && *word' failed
** (python.exe:15036): CRITICAL **: enchant_is_title_case: assertion `word && *word' failed
** (python.exe:15036): CRITICAL **: enchant_is_all_caps: assertion `word && *word' failed
['', 'DEF', 'ABC']
A92产生了一些东西,92P给出了3个关键响应。
在PyEnchant中,关键错误(是他们的错误?)打印到屏幕上,但似乎没有一种机制可以捕获这些错误。我尝试try/except
块
有没有办法测试何时显示“关键”消息并通过不要求拼写建议来消除该消息?
谢谢 - 我没有使用DictWithPWL尝试相同的代码。现在,我根本不允许任何三字符的数字和字母组合,所以我没有遇到这个问题。我也怀疑底层的C库会抛出错误信息,所以我很高兴听到你也说了这个。 –