half-past hours parse as the hour being entered (V-538)

Russian names a half hour by the hour it is entering, in the genitive, so
"половина восьмого" is 07:30 and never 08:30. Neither date parser read that
shape, so the reminder parsed to nothing.

rewriteHalfPast runs in front of the token pass in SpellOutDigits, so the
python parser and the stub both see "в 7:30". It also reads the contracted
"полвосьмого" and the quarter-to shape "без четверти восемь", which counts
from a cardinal and is 07:45. Minus one is in one place, clockHourBefore, with
twelve rather than zero before one.

Ordinals eleven and twelve added to the lexicon, because a clock reaches them.
Minutes a spoken clock does not use are left alone: a guess here is a missed
dose.

Classifier + onnx over the routing fixture 58/82 to 62/87, three new cases,
none regressed. Python dateparser is not installed on this host, so only the
stub was measured. See docs/evals/2026-08-05-half-past-hours.md.
This commit is contained in:
2026-08-05 14:24:49 +04:00
parent f8947bef5a
commit 8bbdcd2727
7 changed files with 306 additions and 2 deletions
+5
View File
@@ -55,6 +55,11 @@ var numeralContext = map[string]bool{
// stands beside it. "три часа" becomes "3 часа"; "три яблока" stays as it is,
// and a note or a fact carrying a spoken number is untouched.
func SpellOutDigits(text string) string {
// A half hour and a quarter-to hour are phrases rather than numerals, and
// the hour they name is one less than the word in them (V-538). They are
// rewritten whole, before the token pass, and come out as digits it leaves
// alone.
text = rewriteHalfPast(text)
toks := strings.Fields(text)
if len(toks) == 0 {
return text