Beispiel #1
0
 def __init__(self,
              stopword_file,
              background_file=[],
              reverse_single=False):
     super(SingleSmarterInterleavedQueryGenerator,
           self).__init__(stopword_file, background_file=background_file)
     self.__single = SingleTermQueryGenerator(stopword_file,
                                              background_file)
     self.__smarter = SmarterQueryGenerator(stopword_file, background_file)
     self.__reverse_single = reverse_single
Beispiel #2
0
class SingleSmarterInterleavedQueryGenerator(BaseQueryGenerator):
    """
    Takes the SingleTermGenerator and the SmarterQueryGenerator, and interleaves like [Single,Smarter,Single,Smarter,Single,Smarter...]
    """
    def __init__(self,
                 stopword_file,
                 background_file=[],
                 reverse_single=False):
        super(SingleSmarterInterleavedQueryGenerator,
              self).__init__(stopword_file, background_file=background_file)
        self.__single = SingleTermQueryGenerator(stopword_file,
                                                 background_file)
        self.__smarter = SmarterQueryGenerator(stopword_file, background_file)
        self.__reverse_single = reverse_single

    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)

        if self.__reverse_single:
            single_queries.reverse()

        smarter_queries = self.__smarter.generate_query_list(search_context)

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

        return interleaved_queries
Beispiel #3
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
Beispiel #5
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)