The hour after "к" is read, and an hour nobody read is asked about (V-610)
"напомни завтра к трём часам дня позвонить врачу" now sets 15:00. It set 03:53, which was the clock at the moment of the turn. She confirmed that as the hour he had just said. #252 taught hourPrepositions and the dateparser rewrite the preposition "к". So HasTime and NamesAnHour started answering true for the sentence. The value did not follow. The rewrite kept his preposition and handed dateparser "завтра к 03:00 pm". dateparser joins a day word to a clock through "в" and through no other Russian preposition. It read the day, dropped the clock and filled the time from its relative base. The completeness rule then saw what, time and day all answered, and committed at the current minute. The preposition is normalised along with the hour now. "на" was losing the clock the same way and was never measured. So "напомни завтра на 9" was landing on the current minute too. The second half is the durable one. ResolvedTheHour is the gate the reminder slot reads, and it refuses a parse whose minute nobody spoke. A spoken hour lands on the hour. The three shapes that name a minute of their own are a written clock, a half hour and a quarter to. Anything else came off the clock the parser was handed. An interval is exempt, because it lands where the arithmetic says. Comparing the whole instant to now is the obvious test and it is wrong. ru-rem-006 resolves to 12:00 and the fixture reference clock is 12:00. That is an hour he did say, reading as an hour nobody did. The five sentences measured on the box are pinned as tests. They run against the stub and against the production parser, and the two that already passed are in there too. Fixture unchanged. classifier+hash is 27/91 and classifier+onnx is 64/91, before and after. reach is 18/30 and 27/30, before and after. No case moved and no clarify count changed. Suite green under -race. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -119,6 +119,55 @@ func NamesAnHour(text string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ResolvedTheHour reports whether a parse read the hour the sentence names,
|
||||
// rather than inheriting the clock it was handed as its relative base.
|
||||
//
|
||||
// It is the second half of the gate NamesAnHour opens (V-610). NamesAnHour asks
|
||||
// whether an hour was spoken and cannot ask whether it was read, so a
|
||||
// preposition the parser half knew wrote a reminder at 03:53 for "напомни
|
||||
// завтра к трём часам дня" and confirmed it as if it were the hour he said. A
|
||||
// wrong instant she states as fact is worse than a question, because he stops
|
||||
// thinking about it.
|
||||
//
|
||||
// The tell is the minute. A spoken hour lands on the hour, and the only three
|
||||
// shapes that name a minute of their own are a written clock, a half hour and a
|
||||
// quarter to. A parse that came back with any other minute took it from the
|
||||
// clock it was handed, whatever hour it put in front of it. An interval is
|
||||
// exempt, because it is measured from now and lands wherever the arithmetic
|
||||
// says.
|
||||
//
|
||||
// Comparing the whole instant to now would be the obvious test and it is the
|
||||
// wrong one: "напомни послезавтра в 12" resolves to 12:00 and the fixture's
|
||||
// reference clock is 12:00, so an hour he did say would read as an hour nobody
|
||||
// did.
|
||||
func ResolvedTheHour(text string, t time.Time) bool {
|
||||
if !NamesAnHour(text) {
|
||||
return false
|
||||
}
|
||||
if NamesAnInterval(text) || t.Minute() == 0 {
|
||||
return true
|
||||
}
|
||||
return namesTheMinute(text)
|
||||
}
|
||||
|
||||
// namesTheMinute reports whether the sentence says which minute of the hour it
|
||||
// means, in any of the three ways it can.
|
||||
func namesTheMinute(text string) bool {
|
||||
toks := strings.Fields(strings.ToLower(text))
|
||||
for i, raw := range toks {
|
||||
if isDigitClock(cleanWord(raw)) {
|
||||
return true
|
||||
}
|
||||
if _, _, ok := halfPastAt(toks, i); ok {
|
||||
return true
|
||||
}
|
||||
if _, _, _, ok := quarterToAt(toks, i); ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// NamesAnInterval reports whether the sentence measures the time from now
|
||||
// instead of naming it: "через час", "через 10 минут", "in 30 minutes".
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user