mesh_search: filler words of a question (did, our, on, all) need not match, so the operator's own words find a tool; a query of filler finds nothing
mesh/delivery merged: source.main moved to novox/mesh-tools@a5097dc69ab2
mesh/check pass 9f25e5c9f6c1 on a5097dc69ab2 | carried from bb6a0e3192db | unit 116 run, 11 kept, 11 skipped | integration 118 run, 11 kept, 10 skippe…
mesh/delivery merged: source.main moved to novox/mesh-tools@a5097dc69ab2
mesh/check pass 9f25e5c9f6c1 on a5097dc69ab2 | carried from bb6a0e3192db | unit 116 run, 11 kept, 11 skipped | integration 118 run, 11 kept, 10 skippe…
This commit is contained in:
@@ -149,3 +149,31 @@ func TestSearchWithoutReplacesMatchesAsBefore(t *testing.T) {
|
||||
t.Errorf("a tool's own name: %+v", hits)
|
||||
}
|
||||
}
|
||||
|
||||
// A question's filler words do not have to match (every other word still does): the operator's own words
|
||||
// find the tool whose description says it in other words; a query of filler alone finds nothing.
|
||||
func TestSearchIgnoresFillerWords(t *testing.T) {
|
||||
x := meshToSearch(t)
|
||||
x.Modules["pacman"] = &moduleInfo{Module: "pacman", On: []string{"anchor"}, Tools: []Tool{{Module: "pacman", Name: "pacman_round",
|
||||
Description: "Whether this week's system upgrade ran on every node (the weekly upgrade round, last run of all nodes)."}}}
|
||||
for _, c := range []struct {
|
||||
query string
|
||||
want string // the first hit's address, "" for none
|
||||
}{
|
||||
{"did our weekly system upgrade run on all our nodes?", "anchor/pacman.pacman_round"},
|
||||
{"the weekly upgrade", "anchor/pacman.pacman_round"},
|
||||
{"did our", ""},
|
||||
{"what is the", ""},
|
||||
{"", ""},
|
||||
{"did our weekly kubernetes upgrade run?", ""},
|
||||
} {
|
||||
hits := x.search(c.query)
|
||||
got := ""
|
||||
if len(hits) > 0 {
|
||||
got = hits[0].Address
|
||||
}
|
||||
if got != c.want || (c.want == "" && len(hits) != 0) {
|
||||
t.Errorf("%q: first hit %q, want %q (%+v)", c.query, got, c.want, hits)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user