-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for fortnight and century #987
base: master
Are you sure you want to change the base?
Added support for fortnight and century #987
Conversation
You seem to have accidentally deleted a file. |
ohk I'm fixing them |
@Gallaecio fixes the files , Now it seems like everything is Ok |
Codecov Report
@@ Coverage Diff @@
## master #987 +/- ##
==========================================
- Coverage 98.29% 98.29% -0.01%
==========================================
Files 234 234
Lines 2702 2700 -2
==========================================
- Hits 2656 2654 -2
Misses 46 46
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see tests only use “century”, in singular. I think it would be good to also cover its plural, both the grammatically correct “centuries” and the supported typo “centurys”.
@Gallaecio ok I'll add them on tests , Thanks for your support and guidance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
in \1 century: | ||
- in (\d+) century? | ||
\1 century ago: | ||
- (\d+) century? ago | ||
in \1 fortnight: | ||
- in (\d+) fortnight? | ||
\1 fortnight ago: | ||
- (\d+) fortnight? ago |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct. The ?
indicates an optional letter.
Doing this it will accepts "in 1 century" but also "in 1 centur". You need to add an s
before the ?
.
Also, you should need to add support for centuries
here.
You can check if both thigns work with this
dateparser.parse("in 3 centurys")
and:
dateparser.parse("in 3 centuries")
Now both are failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noviluni sure fixing the bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noviluni The tests are failing for centuries , even I added them on en.yaml.
@@ -280,10 +280,10 @@ | |||
"(\\d+) decades? ago" | |||
], | |||
"in \\1 century": [ | |||
"in (\\d+) century?" | |||
"in (\\d+) centurys?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it needs to be something like centur(?:ys?|ies)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gallaecio Just tried this , Tests are failing when I used it.
@Gallaecio - I have fixed all the changes that you were request 😊 |
tests/test_freshness_date_parser.py
Outdated
param('last fortnight', ago={'days': 14}, period='day'), | ||
param('14 fortnight', ago={'days': 196}, period='day'), | ||
param('a fortnight ago', ago={'days': 14}, period='day'), | ||
param('last fortnight', ago={'days': 14}, period='day'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is repeated and the same as in line 61.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gutsytechster Done this change, Please Look into it 😊.
tests/test_freshness_date_parser.py
Outdated
param('last fortnight', ago={'days': 14}, period='day'), | ||
param('14 fortnight', ago={'days': 196}, period='day'), | ||
param('a fortnight ago', ago={'days': 14}, period='day'), | ||
param('last fortnight', ago={'days': 14}, period='day'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. It is repeated as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gutsytechster Done this change, Please Look into it 😊.
@@ -841,6 +871,7 @@ def test_relative_past_dates(self, date_string, ago, period): | |||
param('1 वर्ष, 8 महीने, 2 सप्ताह', ago={'years': 1, 'months': 8, 'weeks': 2}, period='week'), | |||
param('1 वर्ष 7 महीने', ago={'years': 1, 'months': 7}, period='month'), | |||
param('आज', ago={'days': 0}, period='day'), | |||
param('1 दशक पहले', ago={'years': 10}, period='year'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a few more test cases for the Hindi version here? For e.g.
- 1 दशक पूर्व
- दो दशक पहले
- 10 दशकों पहले
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gutsytechster Done this change, Please Look into it 😊.
@@ -1160,6 +1199,7 @@ def test_normalized_relative_dates(self, date_string, ago, period): | |||
param('17 सेकंड बाद', in_future={'seconds': 17}, period='day'), | |||
param('1 वर्ष, 5 महीने, 1 सप्ताह में', | |||
in_future={'years': 1, 'months': 5, 'weeks': 1}, period='week'), | |||
param('1 दशक में', in_future={'years': 10}, period='year'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also add a few more test cases for the Hindi version here? For e.g.
- पांच दशक बाद
- दश दशक पश्चात
- 9 दशकों मे
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gutsytechster Done this change, Please Look into it 😊.
@@ -1066,6 +1097,14 @@ def test_normalized_relative_dates(self, date_string, ago, period): | |||
|
|||
@parameterized.expand([ | |||
# English dates | |||
param('in a fortnight', in_future={'days': 14}, period='day'), | |||
param('next fortnight', in_future={'days': 14}, period='day'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, but do we support coming fortnight
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gutsytechster Done this change, Please Look into it 😊.
param('1 दशक', ago={'years': 10}, period='year'), | ||
param('1 दशक पहले', ago={'years': 10}, period='year'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a few suggestions above to improve the Hindi test cases. Please have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gutsytechster Done this change, Please Look into it 😊.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these test cases can be added here as well
- 1 दशक पूर्व
- दो दशक पहले
- 10 दशकों पहले
@@ -10,6 +10,8 @@ november: | |||
- नवम्बर | |||
december: | |||
- दिसम्बर | |||
decade: | |||
- दशक |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add the plural for this as well, e.g. दशकों
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gutsytechster Thanks For Suggestions I'll be Implementing Them ASAP ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gutsytechster Done this change, Please Look into it 😊.
@Gallaecio , @gutsytechster Please Look into it I have done all Changes. |
@Gallaecio Fixed the changes you requested and also add some improvements 👍🏻 |
@@ -51,4 +51,4 @@ docs/_build | |||
.vscode/ | |||
|
|||
# Other | |||
raw_data | |||
raw_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💄 You removed the last empty line 🙂
@@ -73,7 +73,7 @@ relative-type-regex: | |||
- (\d+) decades? ago | |||
in \1 century: | |||
- in (\d+) centurys? | |||
- in (\d+) centur(?:ys?|ies) | |||
- in (\d+) centuries? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the ?
. And add "(\\d+) centuries ago"
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To confirm that you have added the following support
- fortnight support in English
- century support in English
- decade support in Hindi
"(\\d+) दशक मे", | ||
"(\\d+) दशकों मे", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't these same as the first two expressions?
"बाद" | ||
"बाद", | ||
"पश्चात", | ||
"मे" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already present as the first item on this list.
@@ -29,7 +32,44 @@ ago: | |||
in: | |||
- में | |||
- बाद | |||
- पश्चात | |||
- मे |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is repeated as well.
- (\d+) दशक मे | ||
- (\d+) दशकों मे |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeated as the above two expressions.
- (\d+) दशक पहले | ||
- (\d+) दशकों पहले | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nitpick: there is an extra line here.
- दस: '10' | ||
- दश: '10' | ||
- ग्यारह: '11' | ||
- बारह: '12' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add a new line here.
param('1 दशक', ago={'years': 10}, period='year'), | ||
param('1 दशक पहले', ago={'years': 10}, period='year'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these test cases can be added here as well
- 1 दशक पूर्व
- दो दशक पहले
- 10 दशकों पहले
Add support for other words ("decade", "fortnight", "century"...) #725