MCPcopy Create free account
hub / github.com/codemix/graph / createDetailedMatcher

Function createDetailedMatcher

packages/text-search/src/matcher.ts:289–313  ·  view source on GitHub ↗
(
  query: string,
  options: MatcherOptions = {},
)

Source from the content-addressed store, hash-verified

287 * @returns A function that returns detailed match results
288 */
289export function createDetailedMatcher(
290 query: string,
291 options: MatcherOptions = {},
292): (text: string) => MatchResult {
293 const prepared = prepareQuery(query, options);
294 const queryLower = query.toLowerCase().trim();
295
296 // If query is empty, return a function that always returns empty result
297 if (queryLower.length === 0 || prepared.termSet.size === 0) {
298 return () => ({
299 score: 0,
300 termScore: 0,
301 exactBonus: 0,
302 prefixBonus: 0,
303 consecutiveBonus: 0,
304 positionScore: 0,
305 matchedTerms: 0,
306 totalTerms: 0,
307 });
308 }
309
310 return (text: string): MatchResult => {
311 return matchWithDetails(prepared, queryLower, text);
312 };
313}
314
315/**
316 * Internal function to perform matching with full details.

Callers 1

matcher.test.tsFile · 0.85

Calls 2

prepareQueryFunction · 0.85
matchWithDetailsFunction · 0.85

Tested by

no test coverage detected