Repository navigation
Detect the language of text made of multi-word dictionary entries - #1435
Open
AdrianAtZyte wants to merge 4 commits into
Open
AdrianAtZyte wants to merge 4 commits into
AdrianAtZyte wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1435 +/- ##
=======================================
Coverage 99.22% 99.23%
=======================================
Files 239 239
Lines 4256 4290 +34
=======================================
+ Hits 4223 4257 +34
Misses 33 33 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AdrianAtZyte
marked this pull request as ready for review
September 23, 2026 14:27
serhii73
reviewed
Oct 20, 2026
serhii73
left a comment
Collaborator
There was a problem hiding this comment.
Code review (claude code-review, at 2b73aca; compared with the PR's merge-base because the branch is 56 commits behind master). Not approving as is:
- Scores are inflated per word. A multi-word entry now counts once per word, and every locale that has those words as separate single-word entries gets the same inflated score, while locales are ranked by that count first.
detect_language('I will see you next week at noon', languages=None)returnsffon this head (nlat the merge-base;enis the right answer and scores [2,3] against ff's [3,0]), andsearch_dateson that text with auto-detection returns the junk match('see', ...)plus a misdatednext week.count_applicability('next week')goes from [0,0] to [2,0], andMeet me on 5 June next weektiesnnanddjewithen. - Deduplication changed. The set of individual words replaces
set(words)over whole tokens, so tokens that share a word undercount (last weekandnext weekcountweekonce), and scores depend on which phrases happen to share words. - An existing expectation was changed. The Filipino sentence in
tests/test_search.pyflips fromtltofilbecause the inflated scores change which tied locale wins. That edit hides a behaviour change instead of showing it is intended. - Tests are too narrow. They only check text that is a single multi-word entry (
next week,next month). They do not cover mixed text, repeated entries, or several competing languages, so theffresult above passes the suite.
The branch also needs a rebase; #1401 changes _count_words_present_in_the_dictionary too (a guard so padded chunks don't credit parts), so this PR may overlap with it. Counting a multi-word entry once, when all of its words are present, would keep scores comparable.
serhii73
reviewed
Nov 18, 2026
serhii73
left a comment
Collaborator
There was a problem hiding this comment.
Not approving yet:
- The new pattern
\s+(\d+)$(search.py, around line 49) backtracks quadratically on long runs of whitespace. Please anchor or restructure it, and add a test with a long whitespace run. 114 this weeknow reports a number (tests/test_search.py, around line 1825).- Per-word scoring from my earlier review: a multi-word dictionary entry is counted once per word, which inflates scores.
codecov/patchandcodecov/projectfail on this head.
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.
Fixes #1163