def score(question, sentence):
score = 0
sentence = map(ps.stem, sentence)
keywords = getKeywords(question)
question = map(ps.stem, question)
score += proximity(keywords, sentence)
question_ngrams = count_ngrams(question, MAX_NGRAMS, True)
sentence_ngrams = count_ngrams(sentence, MAX_NGRAMS, True)
precision, recall = bleu_score(question_ngrams, len(question), sentence_ngrams, len(sentence), 5)
f1 = (2*precision*recall)/(precision+recall)
score += 2*f1
return score
# Finds the shortest window in the targest sentence
# in which all keywords appear, and assigns a score.
sourceContentSelector.py 文件源码
python
阅读 38
收藏 0
点赞 0
评论 0
评论列表
文章目录