Exemple #1
0
class SingleTriInterleavedQueryGenerator(BaseQueryGenerator):
    """
    Takes the SingleTermGenerator and the TriTermGenerator, and interleaves like [Single,Tri,Single,Tri,Single,Tri...]
    """
    def __init__(self, stopword_file, background_file=[]):
        super(SingleTriInterleavedQueryGenerator,
              self).__init__(stopword_file, background_file=background_file)
        self.__single = SingleTermQueryGenerator(stopword_file,
                                                 background_file)
        self.__tri = TriTermQueryGenerator(stopword_file, background_file)

    def generate_query_list(self, search_context):
        """
        Given a Topic object, produces a list of query terms that could be issued by the simulated agent.
        """

        topic = search_context.topic

        single_queries = self.__single.generate_query_list(search_context)
        tri_queries = self.__tri.generate_query_list(search_context)

        interleaved_queries = [
            val for pair in zip(single_queries, tri_queries) for val in pair
        ]

        return interleaved_queries
class SingleTriInterleavedQueryGenerator(BaseQueryGenerator):
    """
    Takes the SingleTermGenerator and the TriTermGenerator, and interleaves like [Single,Tri,Single,Tri,Single,Tri...]
    """
    def __init__(self, stopword_file, background_file=[]):
        super(SingleTriInterleavedQueryGenerator, self).__init__(stopword_file, background_file=background_file)
        self.__single = SingleTermQueryGenerator( stopword_file, background_file)
        self.__tri = TriTermQueryGenerator(stopword_file, background_file)

    def generate_query_list(self, search_context):
        """
        Given a Topic object, produces a list of query terms that could be issued by the simulated agent.
        """

        topic = search_context.topic

        single_queries = self.__single.generate_query_list(search_context)
        tri_queries = self.__tri.generate_query_list(search_context)
        
        interleaved_queries = [val for pair in zip(single_queries, tri_queries) for val in pair]
        
        return interleaved_queries
Exemple #3
0
 def __init__(self, stopword_file, background_file=[]):
     super(SingleTriInterleavedQueryGenerator,
           self).__init__(stopword_file, background_file=background_file)
     self.__single = SingleTermQueryGenerator(stopword_file,
                                              background_file)
     self.__tri = TriTermQueryGenerator(stopword_file, background_file)
 def __init__(self, stopword_file, background_file=[]):
     super(SingleTriInterleavedQueryGenerator, self).__init__(stopword_file, background_file=background_file)
     self.__single = SingleTermQueryGenerator( stopword_file, background_file)
     self.__tri = TriTermQueryGenerator(stopword_file, background_file)