Skip to content

Support "less than a minute ago" in Russian - #1546

Merged
serhii73 merged 2 commits into
scrapinghub:masterfrom
hammadqureshi-web:ru-less-than-minute-ago
Nov 5, 2026
Merged

serhii73 merged 2 commits into
scrapinghub:masterfrom
hammadqureshi-web:ru-less-than-minute-ago

Conversation

@hammadqureshi-web

@hammadqureshi-web hammadqureshi-web commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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 returned None. 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.yaml had no simplification for this phrase, so the words "меньше"/"минуты" were not translatable.

Scope notes

  • Covers меньше|менее, optionally followed by 1, then минуты назад; одной is turned into 1 by an existing simplification (e.g. "Меньше 1 минуты назад", "менее одной минуты назад", "меньше минуты назад").
  • Other languages are not touched; the issue only gave a Russian example.
  • The "(2 минут)" in the issue text looks like a scraping artifact and is not handled.
  • ru.py is regenerated with python -m dateparser_scripts.write_complete_data.

Test plan

  • dateparser.parse("Меньше 1 минуты назад") returned None before the change and returns a datetime now (with and without languages=["ru"]).
  • pytest tests/test_languages.py: new Russian cases pass.
  • Full 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 check and ruff format --check: clean.

🤖 Generated with Claude Code

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]>
@github-actions github-actions Bot added the spam label Oct 16, 2026
@github-actions github-actions Bot closed this Oct 16, 2026
@codspeed

codspeed Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks


Comparing hammadqureshi-web:ru-less-than-minute-ago (d74628f) with master (2f54bb0)

Open in CodSpeed

@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.09%. Comparing base (ac08823) to head (d74628f).
⚠️ Report is 23 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AdrianAtZyte AdrianAtZyte reopened this Oct 16, 2026
@AdrianAtZyte AdrianAtZyte removed the spam label Oct 16, 2026

@AdrianAtZyte AdrianAtZyte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move the меньше минуты назад test case into the ru block (it landed among the pt ones), and turn one of the 1 cases 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]>
@hammadqureshi-web

Copy link
Copy Markdown
Contributor Author

Thanks! Done in d74628f:

  • Moved меньше минуты назад into the ru block.
  • Changed менее 1 минуты назад to менее одной минуты назад.

While adding that case I found the одной alternative in the regex could never match: the earlier од(ин|на|ну|…|ной|…) → 1 simplification already turns одной into 1 before this rule runs, so the test passed even with the alternative removed. I've dropped it ((?:1\s+)? now). Behaviour is unchanged, and the одной test still passes through that earlier rule, with and without NORMALIZE.

@AdrianAtZyte
AdrianAtZyte requested a review from serhii73 October 27, 2026 10:20

@serhii73 serhii73 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 \b or (?<!\w) would make it robust for search_dates too.
  • Common variants such as меньше минуты тому назад and меньше 1 мин. назад are not matched; fine for a first step, possibly a follow-up.
  • Fixes #371 will 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.

@serhii73
serhii73 merged commit 36317cd into scrapinghub:master Nov 5, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add expression checkers

3 participants