scrapinghub / scrapinghub/dateparser

Search dates fails with french language selector if string contains "-"

Open
#767 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

search_dates Type: Bug - Language
Dominant language
Python
Stars
2.9k
Forks
520
Avg merge
22h 56m
Merged PRs (30d)
6

Description

Version:

  • dateparser==0.7.6

How to reproduce:

# correctly parsed date
search_dates("HelloDate 26.09.2019", languages=["de", "fr"], settings={'DATE_ORDER': 'DMY'})
> [('26.09.2019', datetime.datetime(2019, 9, 26, 0, 0))]

# the "-" in "Hello-Date" leads to a wrong date
search_dates("Hello-Date 26.09.2019", languages=["de", "fr"], settings={'DATE_ORDER': 'DMY'})
> [('2019', datetime.datetime(2019, 8, 12, 0, 0))]

# omitting french language leads to correctly parsed date again
search_dates("Hello-Date 26.09.2019", languages=["de"], settings={'DATE_ORDER': 'DMY'})
Out[9]: [('26.09.2019', datetime.datetime(2019, 9, 26, 0, 0))]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported search_dates examples with dateparser 0.7.6, then trace the search_dates entry point and language handling for French when the input contains a hyphen. Add a regression test covering "Hello-Date 26.09.2019" with German and French, and confirm it returns the full date rather than 2019.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, internationalization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.