Repository navigation
Support "less than a minute ago" in Russian - #1546
Conversation
English already maps "less than 1 minute ago" to "45 second ago", but Russian had no equivalent, so "Меньше 1 минуты назад" was not parsed at all. Add a simplification to the Russian supplementary data (меньше/менее, with an optional "1"/"одной") and regenerate ru.py. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1546 +/- ##
==========================================
+ Coverage 98.97% 99.09% +0.12%
==========================================
Files 239 239
Lines 3600 3988 +388
==========================================
+ Hits 3563 3952 +389
+ Misses 37 36 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
AdrianAtZyte
left a comment
There was a problem hiding this comment.
Please, move the
меньше минуты назадtest case into therublock (it landed among theptones), and turn one of the1cases intoменее одной минуты назадso theоднойbranch is covered.
Move the "меньше минуты назад" case from the Portuguese block into the Russian one, and change "менее 1 минуты назад" to "менее одной минуты назад". The new case showed that the "одной" alternative in the simplification regex could never match: an earlier simplification already rewrites "одной" (and the other forms of "один") to "1". Removing the alternative leaves behaviour unchanged, and the "одной" test still passes through that earlier rule, with and without NORMALIZE. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks! Done in d74628f:
While adding that case I found the |
serhii73
left a comment
There was a problem hiding this comment.
Checked the diff, the linked issue (#371) and CI (19/19 green). I tested the new rule against sample inputs: it matches меньше|менее [1] минуты назад (меньше минуты назад, меньше 1 минуты назад, менее 1 минуты назад) and does not match 2 минуты or 11 минуты. одной is handled by the existing simplification, and the added test covers it. Adrian's approval predates only the review-fix commit d74628f (rule simplified, tests moved); I reviewed the final head. Approving.
Non-urgent notes:
- The rule has no word-boundary guard, so a token that ends in
меньше/менееright beforeминуты назадwould also match (only contrived forms such asнаименьшеdo today). A leading\bor(?<!\w)would make it robust forsearch_datestoo. - Common variants such as
меньше минуты тому назадandменьше 1 мин. назадare not matched; fine for a first step, possibly a follow-up. Fixes #371will close the issue although only Russian is covered;Refs #371(or a follow-up issue for the other languages) may be preferable.- The new tests check translation output only; one
parse("меньше минуты назад", languages=["ru"])case would also guard against a later change in simplification order.
Summary
Issue #371 asks for checkers for "less than 1 minute ago" / "Меньше 1 минуты назад". English already handles the former (
less than 1 minute ago->45 second ago) and Albanian (sq) already exists, but Russian returnedNone. This adds the Russian equivalent, mapped to the same 45 seconds as English.Fixes #371 (for Russian; the English and Albanian parts were already in place).
Root cause
ru.yamlhad no simplification for this phrase, so the words "меньше"/"минуты" were not translatable.Scope notes
меньше|менее, optionally followed by1, thenминуты назад;однойis turned into1by an existing simplification (e.g. "Меньше 1 минуты назад", "менее одной минуты назад", "меньше минуты назад").ru.pyis regenerated withpython -m dateparser_scripts.write_complete_data.Test plan
dateparser.parse("Меньше 1 минуты назад")returnedNonebefore the change and returns a datetime now (with and withoutlanguages=["ru"]).pytest tests/test_languages.py: new Russian cases pass.pytest tests: 24633 passed, 1 failed. The failure (test_freshness_date_with_to_timezone_setting,ZoneInfoNotFoundError) also fails on unmodified master in my environment.ruff checkandruff format --check: clean.🤖 Generated with Claude Code