MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / lineSim

Function lineSim

src/tools/filesystem/fuzzy-match.ts:60–68  ·  view source on GitHub ↗

Token-level Jaccard similarity of two lines (1 = identical token sets).

(a: string, b: string)

Source from the content-addressed store, hash-verified

58
59/** Token-level Jaccard similarity of two lines (1 = identical token sets). */
60function lineSim(a: string, b: string): number {
61 const ta = new Set(tokens(a));
62 const tb = new Set(tokens(b));
63 if (ta.size === 0 && tb.size === 0) return 1;
64 if (ta.size === 0 || tb.size === 0) return 0;
65 let inter = 0;
66 for (const t of ta) if (tb.has(t)) inter++;
67 return inter / (ta.size + tb.size - inter);
68}
69
70/** Mean similarity between two equal-length line arrays. */
71function blockSim(a: string[], b: string[]): number {

Callers 1

blockSimFunction · 0.85

Calls 2

tokensFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected