Ejemplo n.º 1
0
 def __init__(self, name, entity_link_min_score=0.3, topn=50, use_search_cache=True, use_answers_cache=True, **kwargs):
     Ranker.__init__(self, name, **kwargs)
     answers_cache_file = globals.config.get('WebSearchAnswers', 'websearch-answers-cache')
     self._answers_cache = shelve.open(answers_cache_file) if use_answers_cache else dict()
     self._searcher = BingWebSearchApi(globals.config.get('WebSearchAnswers', 'bing-api-key'), use_search_cache)
     self._topn = topn
     self._entity_linking_score_threshold = entity_link_min_score
     self.parameters.web_search_candidates = True
Ejemplo n.º 2
0
    def __init__(self, name, **kwargs):
        Ranker.__init__(self, name, **kwargs)
        answers_file = globals.config.get('WebSearchAnswers', 'websearch-answers')
        self.answers = dict()

        def object_decoder(q):
            rank = int(q['id'].split("-")[1])
            return q['utterance'], q['result'], rank

        self.answers = dict()
        for question, answer, rank in json.load(open(answers_file, 'r'), object_hook=object_decoder, encoding='utf-8'):
            if question not in self.answers:
                self.answers[question] = []
            self.answers[question].append((answer, rank))

        import operator
        for question, answers in self.answers.iteritems():
            self.answers[question] = [answer for answer, rank in sorted(answers, key=operator.itemgetter(1))]
Ejemplo n.º 3
0
 def __init__(self, name, topn=50, **kwargs):
     Ranker.__init__(self, name, **kwargs)
     answers_cache_file = globals.config.get('WebSearchAnswers', 'sentsearch-answers-cache')
     self._answers_cache = shelve.open(answers_cache_file)
     self._searcher = SentSearchApi()
     self._topn = topn