qa.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:NLP_question_answering_system_project 作者: Roshrini 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号