Skip to content
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

Handling whitespace when matching relative dates #916

Open
kss149 opened this issue Apr 28, 2021 · 0 comments · May be fixed by #917
Open

Handling whitespace when matching relative dates #916

kss149 opened this issue Apr 28, 2021 · 0 comments · May be fixed by #917
Labels
Type: Bug - Language Subtype of bug, related to language data

Comments

@kss149
Copy link

kss149 commented Apr 28, 2021

This is for version dateparser==1.0.0.
I've noticed that for some of the dates I tried to parse I need to add spaces to make parsing work and for some I need to remove them.
It seems a bit random and I am guessing it depends on how the string was added to date_translation_data.
That doesn't seem very flexible or reliable, and I wonder if it would make sense to either remove all whitespace from both input data and date_translation_data before matching, or make them optional.

Examples

  • 2 minutes ago in Mandarin
>>> dateparser.parse("2分鐘前")
>>> dateparser.parse("2 分鐘前")                  -> works only if you add space between the number and symbol
datetime.datetime(2021, 4, 28, 20, 45, 19, 266428)
  • 2 months ago in Thai
>>> dateparser.parse("2 เดือน ที่ผ่านมา")            -> doesn't work with space between months and ago
>>> dateparser.parse("2 เดือนที่ผ่านมา")             -> works when you remove space between months and ago
datetime.datetime(2021, 2, 28, 22, 3, 40, 264496)
>>> dateparser.parse("2เดือนที่ผ่านมา")              -> doesn't work when you remove all spaces
@Gallaecio Gallaecio added the Type: Bug - Language Subtype of bug, related to language data label Apr 29, 2021
@noviluni noviluni linked a pull request Apr 29, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug - Language Subtype of bug, related to language data
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants