aec94eb2e8
The score gate cannot separate the right note from an unrelated one: the held-out fixture puts the right note at 0.791-0.890 and the must-be-silent cases at 0.795-0.835, so a note about his slow network answered 'почему небо синее?'. RecallAllowed adds a topic veto, and applies it only to a question that mentions nothing of his. That restriction is the whole design: demanding a shared word of every recall silenced four true recalls on the fixture to kill one false one, because recall exists to find the note whose words he no longer remembers. A question about his own life keeps the embedder as its only judge.
41 lines
1.9 KiB
Go
41 lines
1.9 KiB
Go
package memory
|
|
|
|
import "testing"
|
|
|
|
func TestRecallAllowed(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
query, text string
|
|
want bool
|
|
}{
|
|
// The #470 shape: a world question and a note about his box.
|
|
{"world question, unrelated note", "почему небо синее", "сеть какая-то медленная", false},
|
|
{"world question, unrelated fact", "какая столица Франции", "какая последняя версия языка Go", false},
|
|
{"silent fixture case", "во сколько отходит поезд", "бэкап запускается в три ночи", false},
|
|
|
|
// A world question that does name the topic keeps its answer.
|
|
{"world question, same topic", "какой поезд идёт в Минск", "поезда в Минск ходят утром", true},
|
|
|
|
// A question about his own life is judged by the embedder alone,
|
|
// because recall exists for words he no longer remembers.
|
|
{"about him, no shared word", "во сколько я обычно засыпаю", "ложусь около одиннадцати", true},
|
|
{"about him, english", "which colour scheme do i like", "тёмная тема везде", true},
|
|
|
|
// Inflection must not break a match.
|
|
{"inflected", "чем кормить кота", "корм для кота в шкафу", true},
|
|
}
|
|
for _, c := range cases {
|
|
if got := RecallAllowed(c.query, c.text); got != c.want {
|
|
t.Errorf("%s: RecallAllowed(%q, %q) = %v, want %v", c.name, c.query, c.text, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// A question made only of filler has no topic word to match on, and the score
|
|
// gate is then the only judge it can have.
|
|
func TestRecallAllowedFallsBackWhenNothingToCompare(t *testing.T) {
|
|
if !RecallAllowed("что это", "сеть какая-то медленная") {
|
|
t.Error("a question with no content word must not be vetoed")
|
|
}
|
|
}
|