How many distinct names each segment appears in — the rarity signal that * separates a discriminative word ("checkout") from a ubiquitous one ("state").
(segments: string[])
| 1147 | /** How many distinct names each segment appears in — the rarity signal that |
| 1148 | * separates a discriminative word ("checkout") from a ubiquitous one ("state"). */ |
| 1149 | getSegmentNameCounts(segments: string[]): Map<string, number> { |
| 1150 | if (segments.length === 0 || !this.hasSchema('name_segment_vocab')) return new Map(); |
| 1151 | const placeholders = segments.map(() => '?').join(', '); |
| 1152 | const rows = this.db |
| 1153 | .prepare( |
| 1154 | `SELECT segment, COUNT(*) AS n FROM name_segment_vocab |
| 1155 | WHERE segment IN (${placeholders}) GROUP BY segment`, |
| 1156 | ) |
| 1157 | .all(...segments) as Array<{ segment: string; n: number }>; |
| 1158 | return new Map(rows.map((r) => [r.segment, r.n])); |
| 1159 | } |
| 1160 | |
| 1161 | /** Names containing the given segment (rare-single-word tier). */ |
| 1162 | getNamesForSegment(segment: string, limit: number): string[] { |
no test coverage detected