Пример #1
0
 def clean(self):
     question = self.copy.to_lower('question').split(', ')
     self.copy.question = ''
     for q in question:
         if any(word in q for word in COMMA_REMOVE):
             self.copy.question += q
     if not self.copy.question: self.copy.question = self.original.to_lower('question')
     parallel_execution(self.pool, self.clean_impl, self.fields)
Пример #2
0
 def count_points(self, queries: List[str]):
     res = parallel_execution(self.pool, self.get_page, queries)
     points = parallel_execution(self.pool, self.get_points_from_texts,
                                 [res[0]])
     results = parallel_execution(self.pool, self.get_result_number,
                                  res[1:])
     point = self.select_points(points)
     if sum(point.values()) == 0:
         keys = point.keys()
         for index, key in enumerate(keys):
             point[key] = results[index]
     return self.print_results(point)
def answers_to_text(img: Image.Image, w: int, h: int, question_size: int, pool: ThreadPool, debug: bool) -> List[Any]:
    img = img.point(lambda x: 0 if x < 140 else 255)

    res = parallel_execution(pool, answer_to_text, [
        [img, FIRST_ANSWER_BOUNDARIES(w, h, question_size), debug],
        [img, SECOND_ANSWER_BOUNDARIES(w, h, question_size), debug],
        [img, THIRD_ANSWER_BOUNDARIES(w, h, question_size), debug]
    ])
    if debug: print('The answers are: {}, {}, {}'.format(*res, sep=', '))
    return res
Пример #4
0
    def count_points(self, queries: List[str]):
        res = parallel_execution(self.pool, self.get_page, queries)

        points = parallel_execution(self.pool, self.get_points_from_texts, res)
        point = self.select_points(points)
        return self.print_results(point)
 def clean(self):
     parallel_execution(self.pool, self._add_indexes, self.fields)
Пример #6
0
 def count_points(self, queries):
     res = parallel_execution(self.pool, self.wiki.search, queries)
     summaries = parallel_execution(self.pool, self.get_page, res)
     point = self.count(summaries)
     return self.print_results(point)