Esempio n. 1
0
 def parse(self, log: ProcessLogger, text, text_unit_id, _text_unit_lang, **kwargs) -> ParseResults:
     strict = kwargs.get(Locator.STRICT_DATES_PTR, STRICT_PARSE_DATES.val)
     found = list(dates.get_date_annotations(
         text,
         strict=strict))
     if found:
         _all = [i.date.date() if isinstance(i.date, datetime.datetime)
                 else i.date for i in found]
         return ParseResults({DateUsage: [DateUsage(text_unit_id=text_unit_id,
                                                    date=item,
                                                    count=_all.count(item)) for item in set(_all)]})
Esempio n. 2
0
 def parse(self, text, text_unit_id, _text_unit_lang,
           **kwargs) -> ParseResults:
     strict = kwargs.get('strict', False)
     found = dates.get_dates_list(text, strict=strict, return_source=False)
     if found:
         unique = set([
             i.date() if isinstance(i, datetime.datetime) else i
             for i in found
         ])
         return ParseResults({
             DateUsage: [
                 DateUsage(text_unit_id=text_unit_id,
                           date=item,
                           count=found.count(item)) for item in unique
             ]
         })