c07722266a
Four reminders in a row on the box all landed at the first one's hour, each confirmed as if it had been read from the sentence: "напомни без четверти восемь выходить" fired at 07:30. followUpMerge inherits a missing slot from the previous same-intent turn, and a reminder time is one of those slots. It also filled the slot before actionReminder's own fallback parse could run, so inheriting hid a time that did parse. router.MentionsTime tells the two cases apart. A sentence that names no time still inherits, which is the follow-up the seam exists for. A sentence that names one the parser missed keeps an empty slot, so she asks. Missing the hour he said costs a question; borrowing one costs an alarm he stops thinking about. Signals are lexicon classes and digits only: the day qualifiers, parts of day, day offsets, weekdays by lemma through morph, the half-past and quarter-to markers, and a written clock whose minutes are two digits so a score does not pass for one. Fact keys and act fns inherit through the same call and are left alone: a borrowed key answers about the wrong thing out loud, which he hears, while a borrowed hour is silent until it fires.
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
package router
|
|
|
|
import "testing"
|
|
|
|
func TestMentionsTime(t *testing.T) {
|
|
for _, s := range []string{
|
|
"напомни в семь вечера позвонить маме",
|
|
"напомни в 19:30 позвонить маме",
|
|
"напомни без четверти восемь выходить",
|
|
"напомни в половине первого пообедать",
|
|
"разбуди меня полвосьмого",
|
|
"напомни завтра принять лекарство",
|
|
"напомни в пятницу забрать заказ",
|
|
"напомни через двадцать минут",
|
|
"напомни утром выпить таблетку",
|
|
"remind me at noon to stretch",
|
|
} {
|
|
if !MentionsTime(s) {
|
|
t.Errorf("MentionsTime(%q) = false; this sentence names a time", s)
|
|
}
|
|
}
|
|
}
|
|
|
|
// A sentence with no time in it must not read as one, or a real follow-up stops
|
|
// inheriting the hour it meant.
|
|
func TestMentionsTimeIgnoresSentencesWithoutOne(t *testing.T) {
|
|
for _, s := range []string{
|
|
"напомни позвонить маме",
|
|
"и ещё полить цветы",
|
|
"напомни про счёт за свет",
|
|
"купить три яблока",
|
|
"перезапусти докер",
|
|
"счёт 3:2 в нашу пользу",
|
|
"",
|
|
} {
|
|
if MentionsTime(s) {
|
|
t.Errorf("MentionsTime(%q) = true; there is no time in it", s)
|
|
}
|
|
}
|
|
}
|