def run_for_question(question, number):
    q = Question(number, question, '../docs/top_docs.%d.gz'%number)
    query = BuildQuery.buildQuery(question)
    
    documents = q.search(query)
    rankings = q.golden_passage_retriever(documents)
    passage_metrics = q.test(rankings)
    
    return map(lambda x: float(sum(x)) / len(x), zip(*passage_metrics))
Beispiel #2
0
def justDoIR():
    questions = extract_questions(questions_file)
    output = open("../IRoutput.txt", 'w')
    for qNumber in questions:
        docs = DOCS + "top_docs." + str(qNumber) + ".gz"
        question = Question(qNumber,questions[qNumber],docs)
        # Can do baseline here or do full process.
        # Get expanded question:
        query = questions[qNumber]
        query = BuildQuery.buildFullQuery(query, hyponyms=True, hypernyms=True)
        ir_results = question.search(query)
        for (_,answer) in ir_results:
            output.write(answer+"\n")
    output.close()
Beispiel #3
0
def main():
    questions = extract_questions(questions_file)
    output = open(output_file,"w")
    for qNumber in questions:
        print "\n"
        docs = DOCS + "top_docs." + str(qNumber) + ".gz"
        #print questions[qNumber]
        question = Question(qNumber,questions[qNumber],docs)
        # Can do baseline here or do full process.
        # Get expanded question:
        query = BuildQuery.buildFullQuery(questions[qNumber], hyponyms=False, hypernyms=False)
        print query
        ir_results = question.search(query)
        #print ir_results
        passages = question.golden_passage_retriever(ir_results)
        top5 = question.top5(passages)
        for answer in top5:
            print answer
            output.write(str(qNumber) + " top_docs." + str(qNumber) + " " + answer + "\n")
    output.close()
    if not IS_TEST:
        score = MRR()
        print score
    print "done"