Repository navigation
Fix decimal comma, Roman numeral year and zh search regressions - #1554
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1554 +/- ##
=======================================
Coverage 99.19% 99.20%
=======================================
Files 239 239
Lines 4098 4137 +39
=======================================
+ Hits 4065 4104 +39
Misses 33 33 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I reviewed this and ran it against v1.4.3 and current master. I am not approving yet, because one issue should be fixed before 1.5.0. Blocking: new quadratic time in sanitize_date("a" * 200000 + " 2021 " + "10:00:00,1234 " * 8000)This takes 3.6 s on this branch, against 0.016 s on master and 0.013 s on v1.4.3, and the time doubles with the number of matches. It is the same class of problem as the pending security advisories, and 1.4.3 does not have it. Finding the first run of four digits once avoids it. With the change below the case above takes 0.02 s, the results are unchanged and the full suite passes (25083): Patch+RE_FOUR_DIGITS = re.compile(r"\d{4}")
...
- date_string = RE_SANITIZE_DECIMAL_COMMA.sub(_decimal_comma_to_point, date_string)
+ first_four_digits = RE_FOUR_DIGITS.search(date_string)
+ year_end = first_four_digits.end() if first_four_digits else None
+ date_string = RE_SANITIZE_DECIMAL_COMMA.sub(
+ lambda match: _decimal_comma_to_point(match, year_end), date_string
+ )
...
-def _decimal_comma_to_point(match: re.Match[str]) -> str:
+def _decimal_comma_to_point(match: re.Match[str], year_end: int | None) -> str:
...
- and not re.search(r"\d{4}", match.string, endpos=match.start())
+ and not (year_end is not None and year_end <= match.start())Non-blocking differences from current master (not from v1.4.3), in case you want to look:
|
These tests compare the elapsed wall-clock time with 0.5 s or 1.0 s, and two of them have only about four times of margin on an idle machine (0.26 s and 0.13 s against limits of 1.0 s and 0.5 s). When the machine is busy, the wall-clock time grows without any change in the code: one of them took 1.75 s once in a full-suite run on a loaded machine, and with the CPU oversubscribed four times 17 of 110 executions of these 11 tests failed (9 of 10 for test_search_dates_long_punctuation_run_between_dates and 8 of 10 for test_sanitize_date_long_roman_numeral_run). Use process_time() instead of monotonic(): the same 110 executions under the same load pass, and on the sources of the main branch, which do not have the fixes, the same 8 of the 11 tests still fail with 3 to 9 s against the 1.0 s limit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The Russian handling of compound ordinals, such as "двадцать" and "первое", must not combine two numbers that are written next to each other in a numeric date. Before the main branch changed it, "20 03 2021" was read as the 23rd of the current month in 2021 and "30 01 2020" was not parsed at all. They are the 20th of March 2021 and the 30th of January 2020. Cover that, and that "20 3 мая" is still combined. The two numeric dates fail on the sources of the main branch (2021-11-23 and None) and pass with the changes of this pull request. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Bring the draft in line with master after "Deprecate instead of remove" (scrapinghub#1556): what it turned back into deprecations moves from "Breaking changes" to "Deprecations", and the removal of the public parse() return tuples is dropped because it no longer happens. Check every other entry against the code and 1.4.3: replace examples that behave the same on 1.4.3 or only under explicit languages with ones that show the change, add the caveats a user would trip over (the ngram strategy of the date_formats argument, the locales of the Levantine month names, the default PREFER_MONTH_OF_YEAR for quarters), drop the English label-and-colon example of scrapinghub#1496 because scrapinghub#1482 undid that change, and add the fixes that had no entry: the region argument (scrapinghub#1423), Russian numeric dates (scrapinghub#1554) and the IndexError of search_dates() for zh-Hans, zh-Hant and yue (scrapinghub#1401, scrapinghub#1407). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* Add release notes for 1.5.0 * Update the 1.5.0 release notes Bring the draft in line with master after "Deprecate instead of remove" (#1556): what it turned back into deprecations moves from "Breaking changes" to "Deprecations", and the removal of the public parse() return tuples is dropped because it no longer happens. Check every other entry against the code and 1.4.3: replace examples that behave the same on 1.4.3 or only under explicit languages with ones that show the change, add the caveats a user would trip over (the ngram strategy of the date_formats argument, the locales of the Levantine month names, the default PREFER_MONTH_OF_YEAR for quarters), drop the English label-and-colon example of #1496 because #1482 undid that change, and add the fixes that had no entry: the region argument (#1423), Russian numeric dates (#1554) and the IndexError of search_dates() for zh-Hans, zh-Hant and yue (#1401, #1407). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Serhii A <24910277+serhii73@users.noreply.github.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
No description provided.