Repository navigation
Fix language unique chars - #674
Open
Ronserruya wants to merge 3 commits into
Open
Ronserruya wants to merge 3 commits into
Ronserruya wants to merge 3 commits into
Conversation
Contributor
|
I wonder how hard it would be to change the French and Thai language detection to only trigger if there are no spaces surrounding their respective characters. |
Author
What would that achieve? |
Contributor
|
I imagine the goal of including those characters in language detection was to detect dates in the formats common for those locales. That’s what we loose with this patch. Maybe we can figure out a way to keep the old indented behavior while still fixing the issue. |
1 task done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixed 1 bug and introduces(unveils?) one bug
Bug # 1:
As you can see, including some languages, like French (in addition to English) causes issues with finding dates. This is caused by the
character_check/get_unique_charactersmethods, some languages had punctuations in their "unique characters", for example "-" for French or '.' for Thai.Due to this reason the parser thinks that the text
July 2018 - December 2020is in French and ignores the months.This is fixed by making sure that punctuations don't get into the unique chars set.
Bug # 2
After I fixed this issue I found another issue that was "hidden" before, the following test: https://github.com/scrapinghub/dateparser/blob/master/tests/test_search.py#L670
Only ever worked because of the previous bug,
01.09 – 03.09.2017contains dots, so the parser thought it was in Thai, and used the specific Thai word splitter https://github.com/scrapinghub/dateparser/blob/master/dateparser/languages/locale.py#L256Now that the parser correctly recognizes that the text is not in Thai (so English), it uses the English splitter that splits on dots, which screws up the date.
I tried fixing it as well but I wasn't successful, hopefully you can get it working with your experience with the codebase.
Obviously, due to the second bug, 1 test is failing