Esempio n. 1
0
 def parse(self, log: ProcessLogger, text, text_unit_id, _text_unit_lang, **kwargs) -> ParseResults:
     precision = DEFAULT_FLOAT_PRECIZION
     found = list(amounts.get_amount_annotations(text,
                                                 extended_sources=False,
                                                 float_digits=precision))
     if found:
         unique = set(found)
         return ParseResults({AmountUsage: [AmountUsage(text_unit_id=text_unit_id,
                                                        amount=item.value,
                                                        amount_str=item.text[:300] if item.text else None,
                                                        count=found.count(item)
                                                        ) for item in unique]})
Esempio n. 2
0
 def parse(self, text, text_unit_id, _text_unit_lang,
           **kwargs) -> ParseResults:
     found = list(
         amounts.get_amounts(text,
                             return_sources=True,
                             extended_sources=False))
     if found:
         unique = set(found)
         return ParseResults({
             AmountUsage: [
                 AmountUsage(text_unit_id=text_unit_id,
                             amount=item[0],
                             amount_str=item[1][:300] if item[1] else None,
                             count=found.count(item)) for item in unique
             ]
         })