Repository navigation
fix: match router keywords as whole words - #31
Conversation
|
Thanks @starkhushi , this is a nice fix and the tests are clear! One problem: the endings miss words that double their last letter or drop a final "e". "planning", "debugging" and "programming" now classify as simple (they were moderate on main), and "coding", "comparing" and "summarizing" never matched. Could you handle both cases in compileKeywords? Something like: case len(words) == 1 && strings.HasSuffix(k, "e"): Please also add "planning", "debugging", "coding" and "comparing" to the tests. Thanks! |
|
Thanks @anikchand461, good catch. Done in the latest commit, using your two cases:
Added "planning", "debugging", "programming", "coding", "comparing" and "summarizing" (all moderate) plus "a cod for dinner" (simple) to the tests. |
|
Thanks for merging, @anikchand461! Could you add the |
ClassifycountedcomplexKwswithstrings.Contains, so a keyword matched inside other words and one word could count twice (planin "planets",codein "barcode",buginside "debug",how doinside "how does").Each keyword is now compiled once into a regexp that matches it as a whole word or phrase:
s,es,d,ed,ing), so "explained", "bugs" and "summarised" still count, while "designer", "reasonable" and "programme" don't;analyandoptimistill match any word that starts with them (analysis, optimise, optimization);how dono longer also matches "how does".The keyword list, the weights and the rest of
Classifyare unchanged.tell me about planetswhat is a barcodewhat is a reasonable pricehow does rain form over the sea in the middle of a cold winterhow does+how do)Closes #5
How I tested it
go test ./tests -run "Classify|SelectModel": all pass. Two new tests intests/router_test.go: keywords match only as whole words (the cases above plus endings and stems), andhow does/debugare counted once. Both fail onmain.gofmt -lprints nothing for the two files andgo vet ./app ./testsis clean.CGO_ENABLED=0, so the three database tests that need cgo sqlite (TestConversationLifecycle,TestSearchAndOrdering,TestPersistsAcrossReopen) can't run there; they fail the same way onmain. No device or emulator test, since this is router logic only.