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

Function blockSim

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

Mean similarity between two equal-length line arrays.

(a: string[], b: string[])

Source from the content-addressed store, hash-verified

69
70/** Mean similarity between two equal-length line arrays. */
71function blockSim(a: string[], b: string[]): number {
72 const n = Math.min(a.length, b.length);
73 if (n === 0) return 0;
74 let sum = 0;
75 for (let i = 0; i < n; i++) sum += lineSim(a[i]!, b[i]!);
76 // Penalize length mismatch.
77 const lenPenalty = Math.min(a.length, b.length) / Math.max(a.length, b.length);
78 return (sum / n) * lenPenalty;
79}
80
81/** Convert a [startLine,endLine) line range to char offsets in `content`. */
82function lineRangeToOffsets(lineStarts: number[], content: string, startLine: number, endLine: number): { start: number; end: number } {

Callers 1

findMatchFunction · 0.85

Calls 1

lineSimFunction · 0.85

Tested by

no test coverage detected