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
阻止失败
有没有办法测试何时显示“关键”消息并通过不要求拼写建议来消除该消息?