How many distinct names each segment appears in — the rarity signal that * separates a discriminative word ("checkout") from a ubiquitous one ("state").
(segments: string[])
| 733 | /** How many distinct names each segment appears in — the rarity signal that |
| 734 | * separates a discriminative word ("checkout") from a ubiquitous one ("state"). */ |
| 735 | getSegmentNameCounts(segments: string[]): Map<string, number> { |
| 736 | if (segments.length === 0) return new Map(); |
| 737 | const placeholders = segments.map(() => '?').join(', '); |
| 738 | const rows = this.db |
| 739 | .prepare( |
| 740 | `SELECT segment, COUNT(*) AS n FROM name_segment_vocab |
| 741 | WHERE segment IN (${placeholders}) GROUP BY segment`, |
| 742 | ) |
| 743 | .all(...segments) as Array<{ segment: string; n: number }>; |
| 744 | return new Map(rows.map((r) => [r.segment, r.n])); |
| 745 | } |
| 746 | |
| 747 | /** Names containing the given segment (rare-single-word tier). */ |
| 748 | getNamesForSegment(segment: string, limit: number): string[] { |
no test coverage detected