MCPcopy Create free account
hub / github.com/driangle/taskmd / fuzzyMatchTasks

Function fuzzyMatchTasks

apps/cli/internal/cli/get.go:251–267  ·  view source on GitHub ↗

fuzzyMatchTasks scores all tasks against query, filters by threshold, and returns top 5.

(query string, tasks []*model.Task, threshold float64)

Source from the content-addressed store, hash-verified

249
250// fuzzyMatchTasks scores all tasks against query, filters by threshold, and returns top 5.
251func fuzzyMatchTasks(query string, tasks []*model.Task, threshold float64) []fuzzyMatch {
252 var matches []fuzzyMatch
253 for _, t := range tasks {
254 score := bestFuzzyScore(query, t)
255 if score >= threshold {
256 matches = append(matches, fuzzyMatch{Task: t, Score: score})
257 }
258 }
259 sort.Slice(matches, func(i, j int) bool {
260 return matches[i].Score > matches[j].Score
261 })
262 const maxResults = 5
263 if len(matches) > maxResults {
264 matches = matches[:maxResults]
265 }
266 return matches
267}
268
269// bestFuzzyScore returns the best similarity score between query and the task's ID or title.
270func bestFuzzyScore(query string, task *model.Task) float64 {

Callers 2

TestFuzzyMatchTasksFunction · 0.85
resolveTaskFunction · 0.85

Calls 1

bestFuzzyScoreFunction · 0.85

Tested by 1

TestFuzzyMatchTasksFunction · 0.68