本文整理汇总了Python中dictionary.Dictionary.getSimilarWord方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.getSimilarWord方法的具体用法?Python Dictionary.getSimilarWord怎么用?Python Dictionary.getSimilarWord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dictionary.Dictionary
的用法示例。
在下文中一共展示了Dictionary.getSimilarWord方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getDictMap
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import getSimilarWord [as 别名]
# encoding: utf-8
'''
Created on 2014/9/23
@author: kepler-moment
'''
from dictionary import Dictionary
def getDictMap(path):
fp = open(path,"r")
words = {}
for line in fp.readlines():
word = line.split(":",1)
words[word[0]] = word[1]
#print word[0]
return words
if __name__=='__main__':
#print timeit.timeit("search('Will')", "from __main__ import search", timeit.default_timer, 1)
#print timeit.timeit("binary_search('Will')", "from __main__ import binary_search", timeit.default_timer, 1)
dictionary = Dictionary(getDictMap("./e-c"))
while True:
word = raw_input()
v = dictionary.search(word)
if len(v) == 0:
print dictionary.getSimilarWord(word)
else:
print v