9e1958e7b0
router.WeekdayIndex reads the lexicon and asks the dictionary about the case. Four private lists go away: the habit declension map, the weekday block of the day-plan refusal, the weekday and part-of-day entries of the weather guard, and the stem list in ruwords.go. The stem list was the real defect. mentionsUnknownDay matched sred, pyatnits and subbot with strings.Contains, so sredi, sredstvo and sredniy all read as Wednesday and a question carrying one was answered with onlyNearDaysReply instead of a date. It matches whole tokens now. The weather guard was a third copy of three closed sets that already exist. It kept the rooms of the house, which are its own, and asks the lexicon for the weekdays, the parts of the day and the words that follow v without naming a place. Questions phrased v srede, v utra and v obshchem reached the geocoder as cities before. Full suite green under -race.
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
// TestMentionsUnknownDayReadsWordsNotStems — the defect V-581 found. The
|
|
// weekday half of this guard was a list of stems matched with strings.Contains,
|
|
// so "среди", "средство" and "средний" all read as Wednesday and the question
|
|
// was answered with onlyNearDaysReply instead of a date.
|
|
//
|
|
// The other half of the fix is coverage: a stem list stops at the forms whoever
|
|
// wrote it thought of, and "воскресеньях" was not one of them.
|
|
func TestMentionsUnknownDayReadsWordsNotStems(t *testing.T) {
|
|
for _, u := range []string{
|
|
"какое число в понедельник",
|
|
"какое число в среду",
|
|
"какое число в среде",
|
|
"что там по воскресеньям",
|
|
"what is the date on friday",
|
|
"какое число через неделю",
|
|
} {
|
|
if !mentionsUnknownDay(u) {
|
|
t.Errorf("mentionsUnknownDay(%q) = false, want true", u)
|
|
}
|
|
}
|
|
for _, u := range []string{
|
|
"какое число в среднем",
|
|
"сколько это в среднем",
|
|
"какое сегодня средство",
|
|
"какое число",
|
|
} {
|
|
if mentionsUnknownDay(u) {
|
|
t.Errorf("mentionsUnknownDay(%q) = true; it names no day", u)
|
|
}
|
|
}
|
|
}
|