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

Function weight

src/codegraph/helper-extract.ts:118–122  ·  view source on GitHub ↗
(tf: Map<string, number>)

Source from the content-addressed store, hash-verified

116 const N = base.length;
117 const idf = (t: string): number => Math.log((N + 1) / ((df.get(t) ?? 0) + 1)); // smoothed; token in all docs → ~0
118 const weight = (tf: Map<string, number>): Map<string, number> => {
119 const w = new Map<string, number>();
120 for (const [t, f] of tf) { const iw = idf(t); if (iw > 0) w.set(t, f * iw); }
121 return w;
122 };
123
124 const prepared = base
125 // Weighted vector; fall back to raw tf if weighting empties it (degenerate all-tokens-universal case).

Callers 1

findSimilarHelpersFunction · 0.85

Calls 2

idfFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected