def assign_mod_metadata(meta_data: MetaData) -> MetaData: if not meta_data: meta_data = MetaData() meta_data.has_mod = True else: meta_data.has_mod = True return meta_data
def _digit_number_parse(self, ext_result: ExtractResult) -> ParseResult: result = ParseResult() result.start = ext_result.start result.length = ext_result.length result.text = ext_result.text result.type = ext_result.type result.meta_data = MetaData( ) if not result.meta_data else result.meta_data # [1] 24 # [2] 12 32/33 # [3] 1,000,000 # [4] 234.567 # [5] 44/55 # [6] 2 hundred # dot occurred. power = 1 tmp_index = -1 start_index = 0 handle = ext_result.text.lower() matches = list(regex.finditer(self.config.digital_number_regex, handle)) if matches: for match in matches: rep = self.config.round_number_map.get(match.group()) # \\s+ for filter the spaces. power *= rep tmp_index = handle.find(match.group(), start_index) while tmp_index >= 0: front = handle[0:tmp_index].rstrip() start_index = len(front) handle = front + handle[tmp_index + len(match):] tmp_index = handle.find(match.group(), start_index) # Scale used in the calculate of double result.value = self._get_digital_value(handle, power) return result