708a69375f
A task extracted from mail deduped on the live-norm index only, so once he finished it the row left the live set and the next poll of the same immutable message re-extracted it as a fresh candidate. mavmaild is a read-only reader and marks nothing read, so that repeats forever. Derived rows now carry an ext_id built from the message uid and the extracted span, unique across every status, while voice keeps live-only norm dedupe because saying an errand again is the recurrence signal. A derived source can no longer capture straight to open, and saying a task out loud that Maven had only proposed promotes the candidate instead of answering that it is already in the list. SetTaskStatus was classified AuthRead. Resolving a task is not additive, it erases work off his list, so it is a write, and the row now records the caller that moved it. ListTasks was unbounded. The list-query matcher claimed any utterance with "что мне делать", including "с чем мне помочь", and the urgency stripper matched inside words. Found in review of #60.
88 lines
4.1 KiB
Go
88 lines
4.1 KiB
Go
package router
|
|
|
|
import "testing"
|
|
|
|
func TestParseTaskCapture(t *testing.T) {
|
|
cases := []struct {
|
|
in string
|
|
text string
|
|
weight int
|
|
ok bool
|
|
}{
|
|
{"добавь в задачи купить молоко", "купить молоко", 0, true},
|
|
{"Добавь в список дел: позвонить в банк", "позвонить в банк", 0, true},
|
|
{"запиши задачу починить кран.", "починить кран", 0, true},
|
|
{"новая задача — оплатить интернет", "оплатить интернет", 0, true},
|
|
{"add a task buy milk", "buy milk", 0, true},
|
|
// Urgency he stated out loud, leading or trailing, stripped from the text.
|
|
{"добавь в задачи срочно оплатить интернет", "оплатить интернет", 3, true},
|
|
{"добавь в задачи оплатить интернет срочно", "оплатить интернет", 3, true},
|
|
{"новая задача важно позвонить маме", "позвонить маме", 2, true},
|
|
// The stem inside the task text is part of the task, not a marker.
|
|
{"добавь в задачи позвонить в срочную помощь", "позвонить в срочную помощь", 0, true},
|
|
// Whisper punctuates dictated Russian. The marker used to be missed as
|
|
// soon as anything sat next to it, and then it stayed in the task text
|
|
// and in the dedupe key — the exact task he was trying to flag.
|
|
{"добавь в задачи оплатить интернет, срочно", "оплатить интернет", 3, true},
|
|
{"добавь в задачи очень срочно оплатить интернет", "оплатить интернет", 3, true},
|
|
{"добавь в задачи оплатить интернет — важно", "оплатить интернет", 2, true},
|
|
// A dictated question mark is not part of the task.
|
|
{"добавь в задачи позвонить в банк?", "позвонить в банк", 0, true},
|
|
// The phrasings he uses that the prefix list did not have.
|
|
{"поставь задачу вынести мусор", "вынести мусор", 0, true},
|
|
{"добавь в тудушки купить лампочки", "купить лампочки", 0, true},
|
|
// A marker with nothing after it files nothing.
|
|
{"добавь в задачи", "", 0, false},
|
|
{"новая задача", "", 0, false},
|
|
{"добавь в задачи срочно", "", 0, false},
|
|
// Not a capture: he is talking, not filing.
|
|
{"надо бы поспать", "", 0, false},
|
|
{"я не добавил молоко в список", "", 0, false},
|
|
{"какие у меня задачи?", "", 0, false},
|
|
{"", "", 0, false},
|
|
}
|
|
for _, c := range cases {
|
|
got, ok := ParseTaskCapture(c.in)
|
|
if ok != c.ok || got.Text != c.text || got.Weight != c.weight {
|
|
t.Errorf("ParseTaskCapture(%q) = (%+v, %v), want (%q, w=%d, %v)", c.in, got, ok, c.text, c.weight, c.ok)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestIsTaskListQuery(t *testing.T) {
|
|
yes := []string{
|
|
"какие у меня задачи?",
|
|
"что мне нужно сделать?",
|
|
"покажи список дел",
|
|
"сколько у меня задач?",
|
|
"задачи",
|
|
"мои задачи",
|
|
"what should I do",
|
|
"что мне делать?",
|
|
}
|
|
for _, s := range yes {
|
|
if !IsTaskListQuery(s) {
|
|
t.Errorf("IsTaskListQuery(%q) = false, want true", s)
|
|
}
|
|
}
|
|
no := []string{
|
|
"как дела?",
|
|
// No task noun and no pronoun: these fired ahead of recall and the
|
|
// model, and answered a question about a file or a server with
|
|
// "задач нет."
|
|
"что нужно сделать чтобы перезапустить сервер?",
|
|
"что мне сделать с этим файлом?",
|
|
"what does docker do?",
|
|
"what do you do?",
|
|
"какая погода?",
|
|
"напомни мне позвонить маме в шесть",
|
|
"я сделал зарядку",
|
|
"",
|
|
}
|
|
for _, s := range no {
|
|
if IsTaskListQuery(s) {
|
|
t.Errorf("IsTaskListQuery(%q) = true, want false", s)
|
|
}
|
|
}
|
|
}
|