

from pymur import *
from general_classes import *


class InfoRetriever:


    # builds a QueryEnvironment associated with the indexed document collection
    def __init__(self, index_path):
        # how to get this to link up to the doc collection?

        self.path_to_idx = index_path
        self.index = Index(self.path_to_idx)
        self.query_env = QueryEnvironment()
        self.query_env.addIndex(self.path_to_idx)


    # creates a list of all the passages returned by all the queries generated by
    # the query-processing module
    def retrieve_passages(self, queries):
        passages = []
        for query in queries:
            query = " ".join(query)
            # second argument is the number of documents desired
            docs = self.query_env.runQuery("#combine[passage50:25](" + query + ")", 20)
            for doc in docs:
                doc_num = doc.document
                begin = doc.begin
                end = doc.end
                doc_id = self.query_env.documents([doc_num])[0].metadata['docno'] # need this for output
                passage = Passage(self.index.document(doc_num, True)[begin:end], doc.score, doc_id)
                passages.append(passage)

        return passages





from pymur import *
from general_classes import *
import sys


class InfoRetriever:


    # builds a QueryEnvironment associated with the indexed document collection
    def __init__(self, index_path):
        # how to get this to link up to the doc collection?

        self.path_to_idx = index_path
        self.index = Index(self.path_to_idx)
        self.query_env = QueryEnvironment()
        self.query_env.addIndex(self.path_to_idx)


    # creates a list of all the passages returned by all the queries generated by
    # the query-processing module
    def retrieve_passages(self, queries):
        passages = []
        for query in queries:
            query = " ".join(query)
            sys.stderr.write(query)
            # second argument is the number of documents desired
            docs = self.query_env.runQuery("#combine[passage50:25](" + query + ")", 20)
            for doc in docs:
                doc_num = doc.document
                begin = doc.begin
                end = doc.end
                doc_id = self.query_env.documents([doc_num])[0].metadata['docno'] # need this for output
                passage = Passage(self.index.document(doc_num, True)[begin:end], doc.score, doc_id)
                passages.append(passage)

        return passages



Add debugging statement to retrieve_passages function
Add debugging statement to retrieve_passages function

  
  
  from pymur import *
  from general_classes import *
+ import sys
  
  
  class InfoRetriever:
  
  
      # builds a QueryEnvironment associated with the indexed document collection
      def __init__(self, index_path):
          # how to get this to link up to the doc collection?
  
          self.path_to_idx = index_path
          self.index = Index(self.path_to_idx)
          self.query_env = QueryEnvironment()
          self.query_env.addIndex(self.path_to_idx)
  
  
      # creates a list of all the passages returned by all the queries generated by
      # the query-processing module
      def retrieve_passages(self, queries):
          passages = []
          for query in queries:
              query = " ".join(query)
+             sys.stderr.write(query)
              # second argument is the number of documents desired
              docs = self.query_env.runQuery("#combine[passage50:25](" + query + ")", 20)
              for doc in docs:
                  doc_num = doc.document
                  begin = doc.begin
                  end = doc.end
                  doc_id = self.query_env.documents([doc_num])[0].metadata['docno'] # need this for output
                  passage = Passage(self.index.document(doc_num, True)[begin:end], doc.score, doc_id)
                  passages.append(passage)
  
          return passages
  
  
  
Add debugging statement to retrieve_passages function
## Code Before:


from pymur import *
from general_classes import *


class InfoRetriever:


    # builds a QueryEnvironment associated with the indexed document collection
    def __init__(self, index_path):
        # how to get this to link up to the doc collection?

        self.path_to_idx = index_path
        self.index = Index(self.path_to_idx)
        self.query_env = QueryEnvironment()
        self.query_env.addIndex(self.path_to_idx)


    # creates a list of all the passages returned by all the queries generated by
    # the query-processing module
    def retrieve_passages(self, queries):
        passages = []
        for query in queries:
            query = " ".join(query)
            # second argument is the number of documents desired
            docs = self.query_env.runQuery("#combine[passage50:25](" + query + ")", 20)
            for doc in docs:
                doc_num = doc.document
                begin = doc.begin
                end = doc.end
                doc_id = self.query_env.documents([doc_num])[0].metadata['docno'] # need this for output
                passage = Passage(self.index.document(doc_num, True)[begin:end], doc.score, doc_id)
                passages.append(passage)

        return passages



## Instruction:
Add debugging statement to retrieve_passages function
## Code After:


from pymur import *
from general_classes import *
import sys


class InfoRetriever:


    # builds a QueryEnvironment associated with the indexed document collection
    def __init__(self, index_path):
        # how to get this to link up to the doc collection?

        self.path_to_idx = index_path
        self.index = Index(self.path_to_idx)
        self.query_env = QueryEnvironment()
        self.query_env.addIndex(self.path_to_idx)


    # creates a list of all the passages returned by all the queries generated by
    # the query-processing module
    def retrieve_passages(self, queries):
        passages = []
        for query in queries:
            query = " ".join(query)
            sys.stderr.write(query)
            # second argument is the number of documents desired
            docs = self.query_env.runQuery("#combine[passage50:25](" + query + ")", 20)
            for doc in docs:
                doc_num = doc.document
                begin = doc.begin
                end = doc.end
                doc_id = self.query_env.documents([doc_num])[0].metadata['docno'] # need this for output
                passage = Passage(self.index.document(doc_num, True)[begin:end], doc.score, doc_id)
                passages.append(passage)

        return passages


