def whoRules(question, sentenceOriginal):
score = 0
hasNameQuestion = False
hasNameSentence = False
hasnameSentence = False
hasHumanSentence = False
sentence = sentenceOriginal.lower()
# for chunk in nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(sentenceOriginal))):
# if type(chunk) is nltk.tree.Tree:
# if 'PERSON' in chunk.label() or 'ORGANIZATION' in chunk.label():
# score += 10
for item in question:
if item in NAME:
hasNameQuestion = True
#break
if item in HUMAN and item in sentence:
score += 10
for item in sentence:
if item in NAME:
hasNameSentence = True
if 'name' in item:
hasnameSentence = True
if item in HUMAN:
hasHumanSentence = True
# RULE 2
if not hasNameQuestion and hasNameSentence:
score += 6
# RULE 3
if not hasNameQuestion and hasnameSentence:
score += 4
# RULE 4
if hasNameSentence or hasHumanSentence:
score += 4
return score
# WHAT RULES
qa.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录