Exemple #1
0
def rewrite_apposition(question, candidate):
    return question_apposition(rewriteQuestion(question), candidate)
Exemple #2
0
        answer.replace("<space>", "")
        punc = [".", ",", ":", ".", "?", "!", "'", "\"", ")", "(", "-"]
        question = ''.join([w for w in question if w.lower() not in punc])
        answer = ''.join([w for w in answer if w.lower() not in punc])

        # tokenize the question and answer
        question = (question.lower()).split()
        answer = (answer.lower()).split()

        # straight from the internet...
        m = len(question)
        n = len(answer)
        # An (m+1) times (n+1) matrix
        C = [[0] * (n+1) for i in range(m+1)]
        for i in range(1, m+1):
            for j in range(1, n+1):
                if question[i-1] == answer[j-1]: 
                    C[i][j] = C[i-1][j-1] + 1
                else:
                    C[i][j] = max(C[i][j-1], C[i-1][j])
        return [C[i][j]]

def seq_length_rewrite (question, (answer, doc_num, index, features,q_id)):
    """Rewrites the supplied question and calculates the maximum
       sequence length that the question and the answer have in common.
       
       returns max_seq_len_rewrite (int)
    """
    question = question_rewrite.rewriteQuestion(question)
    return [seq_length_literal(question, (answer, doc_num, index, features,q_id))]
Exemple #3
0
def rewrite_apposition(question, candidate):
    return question_apposition(rewriteQuestion(question), candidate)