Skip to content

[WIP] Parse natural language time - #477

Open
christianfm10 wants to merge 11 commits into
scrapinghub:masterfrom
christianfm10:parse_natural_language_time
Open

christianfm10 wants to merge 11 commits into
scrapinghub:masterfrom
christianfm10:parse_natural_language_time

Conversation

@christianfm10

@christianfm10 christianfm10 commented Jan 5, 2019 •

Copy link
Copy Markdown
Contributor

Fixes #239, fixes #291, fixes #383

@christianfm10
christianfm10 force-pushed the parse_natural_language_time branch from 55a3322 to c7239d5 Compare January 9, 2019 22:16
@codecov

codecov Bot commented Jan 9, 2019 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.81%. Comparing base (bb79181) to head (20ddbaf).
⚠️ Report is 501 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #477      +/-   ##
==========================================
- Coverage   95.21%   92.81%   -2.40%     
==========================================
  Files         302      302              
  Lines        2506     2506              
==========================================
- Hits         2386     2326      -60     
- Misses        120      180      +60     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eLRuLL eLRuLL changed the title WIP Parse natural language time [WIP] Parse natural language time Jan 10, 2019
@eLRuLL

eLRuLL commented Jan 10, 2019

Copy link
Copy Markdown
Contributor

@christianfm10 please be sure to support also days and exactly what was expected by Pawel here: #239 (comment)

@eLRuLL

eLRuLL commented Jan 10, 2019

Copy link
Copy Markdown
Contributor

@christianfm10 also please check the recommendation of Eugene here: #46

I would actually love to follow that one, as I also agree that having the numbers just thrown there as simplifications shouldn't be the way to go, but every language should be able to define their "numbers" and use them to parse the dates better.

Please let me know what do you think and if you think that is the right approach or if we should improve it somehow. Thanks

@asadurski

Copy link
Copy Markdown
Member

Regarding #46, it was planned for, and we already have quite a lot of data to cover that (see https://github.com/scrapinghub/dateparser/tree/master/dateparser_data/cldr_language_data/numeral_translation_data).
My own, shallow, 3 year old efforts are here: https://github.com/scrapinghub/dateparser/tree/feature-numerals-to-numbers. I remember getting to the stage where single (even compound) numeral in a date was recognised correctly, but when it came to several of them, e.g. for year and days, it didn't work.

@Gallaecio Gallaecio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should, after solving conflicts, merge this as is.

This solves the three linked issues (for numbers up to 12). Even if it is not a complete solution for #46, it does not aim to be, and it is an improvement over the current state of things nonetheless.

Regarding @pawelmhm‘s #239 (comment) I think that deserves a separate ticket (if no existing one fits).

@noviluni

Copy link
Copy Markdown
Contributor

I think we could proceed with merging this, but shouldn't this:

>>> parse("today at three o'clock", settings={'PREFER_DATES_FROM': 'future'})
datetime.datetime(2020, 4, 30, 3, 0)

return:

datetime.datetime(2020, 4, 30, 15, 0)

?

cc: @Gallaecio

@noviluni

Copy link
Copy Markdown
Contributor

(of course, my last comment assumes that you are trying it before 3 PM)

@Gallaecio

Copy link
Copy Markdown
Contributor

I agree, although I would not mind opening a separate issue to handle that.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Richer natural language parsing of times Unable to parse 'one week ago' "in three weeks" doesn't work

5 participants