MCPcopy Index your code
hub / github.com/Doorman11991/smallcode / _scoreEntry

Method _scoreEntry

src/knowledge/loader.js:176–189  ·  view source on GitHub ↗

* Score an entry against a query. Higher = more relevant. * Heuristic: each matched keyword = 1 point. Heading match = +2 bonus. * Filename match = +1 bonus.

(entry, queryTokens)

Source from the content-addressed store, hash-verified

174 * Filename match = +1 bonus.
175 */
176 _scoreEntry(entry, queryTokens) {
177 if (queryTokens.length === 0) return 0;
178 let score = 0;
179 const querySet = new Set(queryTokens);
180 for (const kw of entry.keywords) {
181 if (querySet.has(kw)) score += 1;
182 }
183 if (entry.heading) {
184 const headTokens = this._tokenize(entry.heading);
185 for (const t of headTokens) if (querySet.has(t)) score += 2;
186 }
187 if (querySet.has(entry.name.toLowerCase())) score += 1;
188 return score;
189 }
190
191 /**
192 * Pick the most relevant knowledge notes for the given query, fitting under

Callers 1

selectForQueryMethod · 0.95

Calls 2

_tokenizeMethod · 0.95
hasMethod · 0.45

Tested by

no test coverage detected