scrapinghub / dateparser

python parser for human readable dates
BSD 3-Clause "New" or "Revised" License
2.55k stars 465 forks source link

division by zero exceptions trying to parse "Dept.: 0" #497

Closed YehudaItkin closed 4 years ago

YehudaItkin commented 5 years ago

Unable to parse the string: "Dept.: 0" master branch

search_dates("Dept.: 0", languages=['en'], settings={'STRICT_PARSING': True})

File "/usr/local/lib/python3.5/dist-packages/dateparser/search/__init__.py", line 33, in search_dates
    result = _search_with_detection.search_dates(text=text, languages=languages, settings=settings)
  File "/usr/local/lib/python3.5/dist-packages/dateparser/conf.py", line 81, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/dateparser/search/search.py", line 221, in search_dates
    settings=settings)}
  File "/usr/local/lib/python3.5/dist-packages/dateparser/search/search.py", line 153, in search_parse
    original=original, translated=translated, settings=settings)
  File "/usr/local/lib/python3.5/dist-packages/dateparser/search/search.py", line 140, in parse_found_objects
    parsed_best, substrings_best = self.choose_best_split(possible_parsed, possible_substrings)
  File "/usr/local/lib/python3.5/dist-packages/dateparser/search/search.py", line 59, in choose_best_split
    rating.append([num_substrings, float(not_parsed)/float(num_substrings),
ZeroDivisionError: float division by zero
asadurski commented 5 years ago

Hello @YehudaItkin, I can't reproduce the exception with the new version (it should be covered by https://github.com/scrapinghub/dateparser/pull/429). Can you confirm that?

Gallaecio commented 4 years ago

Closing due to a lack of feedback.