def includes(answer,question):

    count = 0
    sentences_qus= sent_tokenize(question)
    matching_count = 0

    for sentence_qus in sentences_qus:
      top = keywords.top(sentence_qus, nouns=True)
      words_ans = word_tokenize(answer)
      words_qus = word_tokenize(sentence_qus)
      for word_qus in words_qus:
       if word_qus == 'Include' or word_qus == 'include' or word_qus == 'Include:' :

          for count,word in top:
              for word_ans in words_ans:
                    if word == word_ans:
                        print word
                        matching_count = matching_count+1
                        #print matching_count

          #print len(top)
       defferent = len(top)- matching_count
       if (defferent+2)== 0 or (defferent+2)== 1 or (defferent+2)== 2:
             count = count + 0.5
    return count
Esempio n. 2
0
def note_body(answer,question):

    count = 0
    sentences_qus= sent_tokenize(question)

    for sentence_qus in sentences_qus:
          top = keywords.top(sentence_qus)
          words_ans = word_tokenize(answer)
          matching_count = 0
          for count,word in top:
              for word_ans in words_ans:
                    if word == word_ans:
                        print word
                        matching_count = matching_count+1

          different = len(top)- matching_count
          if (different+2)== 0 or (different+2)== 1 or (different+2)== 2:
             count = count + 0.5

    return count