@@ -0,0 +1,1424 @@
+# LING 573 Question Answering System%0A# Code last updated 4/17/14 by Clara Gordon%0A# This code implements an InfoRetriever for the question answering system.%0A%0A%0A# from pymur import *%0Afrom general_classes import *%0Aimport sys%0Aimport subprocess%0A%0A%0Aclass InfoRetriever:%0A%0A    indri_loc = %22/NLP_TOOLS/info_retrieval/indri/latest/bin/IndriRunQuery%22%0A%0A    # builds a QueryEnvironment associated with the indexed document collection%0A    def __init__(self, index_path):%0A        # how to get this to link up to the doc collection?%0A%0A        self.path_to_idx = index_path%0A%0A%0A    # creates a list of all the passages returned by all the queries generated by%0A    # the query-processing module%0A    def retrieve_passages(self, queries):%0A%0A        passages = %5B%5D%0A        for query in queries:%0A            # query = %22 %22.join(query.search_terms.keys())%0A            sys.stderr.write(query + '%5Cn')%0A            # second argument is the number of documents desired%0A            try:%0A                p1 = subprocess.Popen(%5Bself.indri_loc, %22%22.join(%22-index=%22, self.path_to_idx), %5C%0A                               %22%22.join(%22-query=%22, '%22#combine(%22', query,')%22'), %22-printSnippets=true%22%5D, %5C%0A                                      stdout=subprocess.PIPE, shell=True)%0A                results = (p1.communicate())%0A                print results%0A            except:%0A                except:%0A                sys.stderr.write(%22Couldn't run query: %22 + query + '%5Cn')%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A

Add experimental info_retrieval2