42d7a39c49
The three callers now read their sentences out of summary_ru_v1.json: the
plan lines in morning.Plan.FormatRU, the list and reason words in
tasks.FormatRU, and the habit readouts in memory.Profile.
Two behaviour_test assertions moved from substring to say.IsS, because the
habit gaps have variants now and a substring pins one of them. The
"по {day} у тебя обычно" variant was dropped on sight: the activities are
verbs, so it read "у тебя обычно тренируешься".
The persona scorer covers the family, and a new test asserts every gap
variant still says she has not seen enough rather than that he has nothing.
71 lines
2.4 KiB
Go
71 lines
2.4 KiB
Go
package eval
|
|
|
|
import (
|
|
"math/rand"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/kami/maven/internal/phraser"
|
|
"github.com/kami/maven/internal/say"
|
|
)
|
|
|
|
// TestFallbackPersona scores every line in every hand-written family on the
|
|
// persona checks the nudges already pass. These lines are heard out loud and
|
|
// they live in a JSON file now, so a reworded variant that says "рад" or "вы"
|
|
// would otherwise reach him with nothing in between.
|
|
//
|
|
// Only the persona checks run. Mood and topic belong to a nudge, and these are
|
|
// not nudges.
|
|
func TestFallbackPersona(t *testing.T) {
|
|
fb, err := phraser.LoadFallbacks(rand.NewSource(20260804))
|
|
if err != nil {
|
|
t.Fatalf("LoadFallbacks: %v", err)
|
|
}
|
|
// No CheckHisGender. It reads a feminine verb near a second-person pronoun
|
|
// as addressing him as a woman, which is right for a nudge and wrong here:
|
|
// "не знаю — не нашла у тебя такой записи" is her own verb in her own
|
|
// sentence. CheckFeminine still holds her side of the rule.
|
|
persona := map[string]bool{
|
|
CheckLang: true, CheckFeminine: true,
|
|
CheckAddress: true, CheckCringe: true, CheckLength: true,
|
|
}
|
|
ack, err := phraser.LoadAcks(rand.NewSource(20260804))
|
|
if err != nil {
|
|
t.Fatalf("LoadAcks: %v", err)
|
|
}
|
|
qry, err := phraser.LoadQueries(rand.NewSource(20260804))
|
|
if err != nil {
|
|
t.Fatalf("LoadQueries: %v", err)
|
|
}
|
|
variants := append(fb.Variants(), ack.Variants()...)
|
|
variants = append(variants, qry.Variants()...)
|
|
act, err := phraser.LoadActs(rand.NewSource(20260804))
|
|
if err != nil {
|
|
t.Fatalf("LoadActs: %v", err)
|
|
}
|
|
variants = append(variants, act.Variants()...)
|
|
sum, err := say.LoadSummaries(rand.NewSource(20260804))
|
|
if err != nil {
|
|
t.Fatalf("LoadSummaries: %v", err)
|
|
}
|
|
variants = append(variants, sum.Variants()...)
|
|
if len(variants) == 0 {
|
|
t.Fatal("no variants — the file loaded empty")
|
|
}
|
|
for _, v := range variants {
|
|
// The placeholders stand for his own words and carry no persona.
|
|
body := v
|
|
for _, ph := range []string{"{sources}", "{key}", "{value}", "{fn}", "{text}", "{when}", "{items}",
|
|
"{location}", "{temp}", "{condition}", "{tail}", "{out}", "{name}",
|
|
"{entity}", "{count}", "{word}",
|
|
"{date}", "{line}", "{n}", "{day}", "{sat}", "{sun}", "{span}", "{gloss}", "{time}"} {
|
|
body = strings.ReplaceAll(body, ph, "вода")
|
|
}
|
|
for _, r := range RunChecks(Case{}, body, "neutral") {
|
|
if persona[r.Name] && !r.Pass {
|
|
t.Errorf("%q fails %s: %s", v, r.Name, r.Detail)
|
|
}
|
|
}
|
|
}
|
|
}
|