scrapinghub / scrapinghub/dateparser
`dateparser.search.search_parse` fails to parse trivial examples, except US locale
Open
Nobody has claimed this yet.
search_dates
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
def search_parse(self, shortname, text, settings):
translated, original = self.search(shortname, text, settings)
bad_translate_with_search = ['vi', 'hu'] # splitting done by spaces and some dictionary items contain spaces
if shortname not in bad_translate_with_search:
parser = DateDataParser(languages=['en'], settings=settings)
parsed, substrings = self.parse_found_objects(parser=parser, to_parse=translated,
original=original, translated=translated, settings=settings)
else:
...
The order of month and day is preserved from original language, but string is parsed as english. This introduces an error for european languages which don't use US MDY order. Simple negative example:
>>> from dateparser import search as datesearch
>>> datesearch.search_dates('10.09.2020', languages=['de'], settings={"STRICT_PARSING": True, "PARSERS": ["absolute-time"]})
[('10.09.2020', datetime.datetime(2020, 10, 9, 0, 0))]
Should be
[('10.09.2020', datetime.datetime(2020, 9, 10, 0, 0))]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the German example through dateparser.search.search_parse with STRICT_PARSING and the absolute-time parser. Trace how the translated text is passed to the English DateDataParser, then add coverage for the expected 10 September 2020 result and verify that the existing US-locale behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- internationalization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100