scrapinghub / scrapinghub/dateparser
search_dates: problem with numeric incomplete dates
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
Issue may be in part related to #846
I have trouble to make search_dates recognise numeric incomplete dates correctly, such as 05/2020 or 2020.
-
In the first case, the 05 is recognised as day (and not as month, even though DATE_ORDER is DMY). Even more interesting is that the "month" in the datetime object depends on previously detected months.
--> incomplete data matching should recognises the DATE_ORDER argument (thus recognising this as month) or date_formats could be supplied to search_dates, so that %m/%Y can be defined as date format. -
the year is recognised, the day is set according to PREFERED_DAY_OF_MONTH, but the month is set the months recognised earlier in the text.
--> would it be possible to have a PREFERED_MONTH_OF_YEAR option?
Text1: "test 01.05.2020 test. test 06/07/2020. test 05/2020. test 2020"
Result1: [('01.05.2020', datetime.datetime(2020, 5, 1, 0, 0)), ('06/07/2020', datetime.datetime(2020, 7, 6, 0, 0)), ('05/2020', datetime.datetime(2020, 7, 5, 0, 0)), ('2020', datetime.datetime(2020, 7, 1, 0, 0))]
Text2: "test 01.05.2020 test. test 06/10/2020. test 05/2020. test 2020"
Result2: [('01.05.2020', datetime.datetime(2020, 5, 1, 0, 0)), ('06/10/2020', datetime.datetime(2020, 10, 6, 0, 0)), ('05/2020', datetime.datetime(2020, 10, 5, 0, 0)), ('2020', datetime.datetime(2020, 10, 1, 0, 0))]
The first two dates are correct, the the third and fourth are not.
Thanks a lot :)
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 at the search_dates entry point and reproduce the Text1 and Text2 examples from the issue. Trace how incomplete numeric dates use DATE_ORDER, PREFERED_DAY_OF_MONTH, and previously detected months, then define behavior for 05/2020 and 2020 and verify that the reported results no longer depend on earlier dates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100