MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / getSegmentNameCounts

Method getSegmentNameCounts

src/db/queries.ts:1149–1159  ·  view source on GitHub ↗

How many distinct names each segment appears in — the rarity signal that * separates a discriminative word ("checkout") from a ubiquitous one ("state").

(segments: string[])

Source from the content-addressed store, hash-verified

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[] {

Calls 5

hasSchemaMethod · 0.95
mapMethod · 0.80
allMethod · 0.65
prepareMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected