Ejemplo n.º 1
0
 def _update_parser_ranges_with_or_linkage(self, effect_clues, effect_group,
                                           effect_group_type,
                                           parser_ranges):
     """
     This method updates parsers ranges, when rule constraints are connected
     by OR linkage, to maximal possibly range. If we find constraint that hasn't delta we can't
     limit parser's search ranges for all parser connected by this constraint.
     """
     effect_group_value = \
         effect_clues[self.get_effect_name()].regex_parameters[effect_group - 1]
     for constraint in self._constraints:
         if constraint['name'] in self.DELTA_CONSTRAINTS:
             continue
         for parser_number, _ in constraint['clues_groups']:
             if parser_number == EFFECT_NUMBER:
                 continue
             _, primary_group_type = self._causes[
                 parser_number - 1].get_primary_key_group()
             converter = DeltaConverterFactory.get_converter(
                 primary_group_type)
             new_right_bound = converter.MAX_VALUE
             if primary_group_type == effect_group_type:
                 new_right_bound = effect_group_value
             primary_group_type_bound = parser_ranges[parser_number][
                 primary_group_type]
             primary_group_type_bound[
                 InvestigationStep.RIGHT_BOUND] = new_right_bound
             primary_group_type_bound[
                 InvestigationStep.LEFT_BOUND] = converter.MIN_VALUE
Ejemplo n.º 2
0
 def _calculate_parser_bounds(self, base_parser_number, params, group_type,
                              parser_ranges):
     """
     This method calculate depended parser search range basing on base parser search range.
     """
     max_delta = params.get('max_delta')
     min_delta = params.get('min_delta')
     left_bound, right_bound = self._get_base_bounds(
         base_parser_number, group_type, parser_ranges)
     converter = DeltaConverterFactory.get_converter(group_type)
     new_left_bound = converter.switch_by_delta(
         left_bound, max_delta, DeltaConverter.MAX_DELTA_TYPE)
     new_right_bound = converter.switch_by_delta(
         right_bound, min_delta, DeltaConverter.MIN_DELTA_TYPE)
     return {
         group_type: {
             InvestigationStep.LEFT_BOUND: new_left_bound,
             InvestigationStep.RIGHT_BOUND: new_right_bound
         }
     }
Ejemplo n.º 3
0
 def create_ranges_for_unconnected_parsers(
     self, effect_clues, effect_primary_group, effect_group_type, parser_ranges
 ):
     """
     Create maximal search range for parsers which are unreachable in connectivity parsers graph
     from effect parser.
     """
     effect_primary_group_value = effect_clues[self.get_effect_name(
     )].regex_parameters[effect_primary_group - 1]
     for i in six.moves.range(len(self._causes)):
         if (i + 1) not in parser_ranges:
             _, primary_group_type = self._causes[i].get_primary_key_group()
             converter = DeltaConverterFactory.get_converter(primary_group_type)
             right_bound = converter.MAX_VALUE
             if primary_group_type == effect_group_type:
                 right_bound = effect_primary_group_value
             parser_ranges[(i + 1)] = {
                 primary_group_type: {
                     InvestigationStep.LEFT_BOUND: converter.MIN_VALUE,
                     InvestigationStep.RIGHT_BOUND: right_bound
                 }
             }
Ejemplo n.º 4
0
 def _calculate_parser_bounds(self, base_parser_number, params, group_type, parser_ranges):
     """
     This method calculate depended parser search range basing on base parser search range.
     """
     max_delta = params.get('max_delta')
     min_delta = params.get('min_delta')
     left_bound, right_bound = self._get_base_bounds(
         base_parser_number, group_type, parser_ranges
     )
     converter = DeltaConverterFactory.get_converter(group_type)
     new_left_bound = converter.switch_by_delta(
         left_bound, max_delta, DeltaConverter.MAX_DELTA_TYPE
     )
     new_right_bound = converter.switch_by_delta(
         right_bound, min_delta, DeltaConverter.MIN_DELTA_TYPE
     )
     return {
         group_type: {
             InvestigationStep.LEFT_BOUND: new_left_bound,
             InvestigationStep.RIGHT_BOUND: new_right_bound
         }
     }
Ejemplo n.º 5
0
 def _update_parser_ranges_with_or_linkage(
     self, effect_clues, effect_group, effect_group_type, parser_ranges
 ):
     """
     This method updates parsers ranges, when rule constraints are connected
     by OR linkage, to maximal possibly range. If we find constraint that hasn't delta we can't
     limit parser's search ranges for all parser connected by this constraint.
     """
     effect_group_value = \
         effect_clues[self.get_effect_name()].regex_parameters[effect_group - 1]
     for constraint in self._constraints:
         if constraint['name'] in self.DELTA_CONSTRAINTS:
             continue
         for parser_number, _ in constraint['clues_groups']:
             if parser_number == EFFECT_NUMBER:
                 continue
             _, primary_group_type = self._causes[parser_number - 1].get_primary_key_group()
             converter = DeltaConverterFactory.get_converter(primary_group_type)
             new_right_bound = converter.MAX_VALUE
             if primary_group_type == effect_group_type:
                 new_right_bound = effect_group_value
             primary_group_type_bound = parser_ranges[parser_number][primary_group_type]
             primary_group_type_bound[InvestigationStep.RIGHT_BOUND] = new_right_bound
             primary_group_type_bound[InvestigationStep.LEFT_BOUND] = converter.MIN_VALUE
Ejemplo n.º 6
0
 def create_ranges_for_unconnected_parsers(self, effect_clues,
                                           effect_primary_group,
                                           effect_group_type,
                                           parser_ranges):
     """
     Create maximal search range for parsers which are unreachable in connectivity parsers graph
     from effect parser.
     """
     effect_primary_group_value = effect_clues[
         self.get_effect_name()].regex_parameters[effect_primary_group - 1]
     for i in six.moves.range(len(self._causes)):
         if (i + 1) not in parser_ranges:
             _, primary_group_type = self._causes[i].get_primary_key_group()
             converter = DeltaConverterFactory.get_converter(
                 primary_group_type)
             right_bound = converter.MAX_VALUE
             if primary_group_type == effect_group_type:
                 right_bound = effect_primary_group_value
             parser_ranges[(i + 1)] = {
                 primary_group_type: {
                     InvestigationStep.LEFT_BOUND: converter.MIN_VALUE,
                     InvestigationStep.RIGHT_BOUND: right_bound
                 }
             }