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

Method getSegmentNameCounts

src/db/queries.ts:1151–1161  ·  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

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