(tokens: Token[])
| 154 | * @returns Map of stemmed term to array of positions |
| 155 | */ |
| 156 | export 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 | } |
no test coverage detected