本文整理汇总了Python中search.Search.delayed_hits方法的典型用法代码示例。如果您正苦于以下问题:Python Search.delayed_hits方法的具体用法?Python Search.delayed_hits怎么用?Python Search.delayed_hits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search.Search
的用法示例。
在下文中一共展示了Search.delayed_hits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: score_phrases
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import delayed_hits [as 别名]
def score_phrases(input_file,output_file):
# open files
fi = open(Scorer.phrasesRoot+input_file, 'r')
fo = open(Scorer.phrasesRoot+output_file, 'w')
# get hits of "poor" and "excellent"
hits_poor = Search.delayed_hits("poor")
hits_exc = Search.delayed_hits("excellent")
# iterate input file
for phrase in fi:
phrase = re.sub("\s+$","", phrase)
hits_ph_poor = Search.delayed_hits("\""+phrase+"\" NEAR poor")
hits_ph_exc = Search.delayed_hits("\""+phrase+"\" NEAR excellent")
so = 0
if(hits_ph_poor > 0 and hits_exc > 0 and hits_ph_exc > 0 and hits_poor > 0):
so = math.log((hits_ph_exc * hits_poor)/(hits_ph_poor * hits_exc),2)
fo.write(phrase+" "+str(so)+"\n")
fo.flush()
fi.close()
fo.close()