You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there is something wrong in dateparser prioritization of languages, as introducing 'en' even in the last position hurts extraction of dates that were extracted properly when English was not there.
We got it parsed like in English, even if Spanish is first in the list of languages. This is unexpected to me, I would have expected prioritizing Spanish instead.
The currently used order is that order defined in dateparser/dateparser/data/languages_info.py (FYI, this order is being questioned in this issue (#714) and it will probably change).
However, I agree that people using the languages parameter could expect it to respect the defined order. So we should probably change this behavior or document it.
This could be addressed by adding a setting (called, for example, USE_GIVEN_LANGUAGE_ORDER) and possibly making it True by default. The logic to implement this is practically finished, as we have the use_given_order property when creating the DateDataParser object, and we should just add a small portion of code and tests to allow this setting to work.
I will tag this as good_first_issue and I expect this to be solved before the end of October (or should I say "Hacktoberfest")? 🙂
Thank you for your comment! 😄
Reacted by Adrián Chaves, Iván de Prado and Konstantin Lopuhin
Just to give you more context: The idea is that the languages provided to dateparser can come from a language detector model run over the page (this is my case). This gives you a list of languages, ordered by probability: the first one is the more probable, then the second one, etc.
So the idea is to give them to dateparser as a language hint, and the order is important in this case. Probably USE_GIVEN_LANGUAGE_ORDER will help in the case I'm describing. 👍
I added a pr for this, please take a look and let me know what you think about this implementation and I will fix and add some tests for it as well if so.
I believe the default should be False so that we make use of the list of most common languages for this @noviluni
Activity
noviluni commentedon Aug 25, 2020
Hi @ivanprado!
The currently used order is that order defined in
dateparser/dateparser/data/languages_info.py(FYI, this order is being questioned in this issue (#714) and it will probably change).However, I agree that people using the
languagesparameter could expect it to respect the defined order. So we should probably change this behavior or document it.This could be addressed by adding a setting (called, for example,
USE_GIVEN_LANGUAGE_ORDER) and possibly making itTrueby default. The logic to implement this is practically finished, as we have theuse_given_orderproperty when creating theDateDataParserobject, and we should just add a small portion of code and tests to allow this setting to work.I will tag this as
good_first_issueand I expect this to be solved before the end of October (or should I say "Hacktoberfest")? 🙂Thank you for your comment! 😄
ivanprado commentedon Aug 25, 2020
Thank you @noviluni, this sounds great 😄 .
Just to give you more context: The idea is that the languages provided to
dateparsercan come from a language detector model run over the page (this is my case). This gives you a list of languages, ordered by probability: the first one is the more probable, then the second one, etc.So the idea is to give them to
dateparseras a language hint, and the order is important in this case. ProbablyUSE_GIVEN_LANGUAGE_ORDERwill help in the case I'm describing. 👍dariuschira commentedon Sep 17, 2020
Hi @noviluni @ivanprado ,
I added a pr for this, please take a look and let me know what you think about this implementation and I will fix and add some tests for it as well if so.
I believe the default should be
Falseso that we make use of the list of most common languages for this @noviluniserhii73 commentedon Dec 1, 2022
We can close this issue because it was fixed in #805 and #845
Gallaecio commentedon Dec 1, 2022
@serhii73 Your output shows that it is still not fixed.
Out [4]will matchOut [3]once the issue is fixed,serhii73 commentedon Dec 1, 2022
Yes, you're right @Gallaecio
Finalize USE_GIVEN_LANGUAGE_ORDER: keep use_given_order, no-op on emp…
Locale order support (#789)