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

Function buildPositionMap

packages/text-search/src/tokenizer.ts:156–167  ·  view source on GitHub ↗
(tokens: Token[])

Source from the content-addressed store, hash-verified

154 * @returns Map of stemmed term to array of positions
155 */
156export function buildPositionMap(tokens: Token[]): Map<string, number[]> {
157 const positions = new Map<string, number[]>();
158 for (const token of tokens) {
159 const existing = positions.get(token.stemmed);
160 if (existing) {
161 existing.push(token.position);
162 } else {
163 positions.set(token.stemmed, [token.position]);
164 }
165 }
166 return positions;
167}

Callers 2

tokenizer.test.tsFile · 0.85
matchWithDetailsFunction · 0.85

Calls 2

getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected