package eval import "testing" func TestAddressTimeWordDoesNotBlind(t *testing.T) { // A nudge that opens with a time word must still be caught. Without the // time words in the stoplist, "сегодня" was read as the third party. for _, s := range []string{ "сегодня он не ел 11 дней", "вчера он не пил воду", "опять он забыл про таблетки", } { if r := checkAddress(s); r.Pass { t.Errorf("checkAddress(%q) passed, want a third-person failure", s) } } // Still must not fire when a third party really is named. for _, s := range []string{ "сегодня сервис упал, он не отвечает", "ты не пил воду четыре часа", } { if r := checkAddress(s); !r.Pass { t.Errorf("checkAddress(%q) failed: %s", s, r.Detail) } } } // TestAddressVerbIsNotAnAntecedent — a nudge is mostly verbs, and a verb is // never who "он" refers to. This exact string passed the check before. func TestAddressVerbIsNotAnAntecedent(t *testing.T) { s := "попробуй встать и отдохнуть — у него есть перерыв" if r := checkAddress(s); r.Pass { t.Errorf("checkAddress(%q) passed, want a third-person failure", s) } // Still missed, and this is the documented hole: "выпей воды, он не пил" has // a real noun ("воды") before the pronoun, so the scan believes somebody // else was named. Telling that apart needs a parser, not a suffix rule. // A named third party still wins over the verbs around it. if r := checkAddress("сервис упал, он не отвечает"); !r.Pass { t.Errorf("checkAddress on a real third party failed: %s", r.Detail) } }