本文整理汇总了Python中dictionary.Dictionary.has_word方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.has_word方法的具体用法?Python Dictionary.has_word怎么用?Python Dictionary.has_word使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dictionary.Dictionary
的用法示例。
在下文中一共展示了Dictionary.has_word方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Dictionary
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import has_word [as 别名]
n_right = 0
n_unknown = 0
n_wrong = 0
n_total = 0
dictionary = Dictionary()
for line in fh:
right, wrongs = line.split(':')
wrongs = [w.strip() for w in wrongs.split(',')]
print right + ':'
for wrong in wrongs:
if dictionary.has_word(wrong.lower()):
continue
n_total += 1
sc = Spellcheck(wrong)
guess = sc.corrected()[0][0]
print '\t%s => %s\t' % (wrong, guess),
if guess == right:
print 'CORRECT!'
n_right += 1
elif guess == wrong:
print 'UNKNOWN'
n_unknown += 1