MCPcopy Create free account
hub / github.com/SamuelZ12/longcut / getTranscriptFormatStats

Function getTranscriptFormatStats

lib/transcript-format-detector.ts:118–146  ·  view source on GitHub ↗
(transcript: TranscriptSegment[])

Source from the content-addressed store, hash-verified

116 * Gets statistics about a transcript format for debugging/monitoring
117 */
118export function getTranscriptFormatStats(transcript: TranscriptSegment[]) {
119 if (!transcript || transcript.length === 0) {
120 return {
121 segmentCount: 0,
122 avgTextLength: 0,
123 sentenceEndingRatio: 0,
124 format: 'unknown' as const
125 };
126 }
127
128 const sampleSize = Math.min(100, transcript.length);
129 const sample = transcript.slice(0, sampleSize);
130
131 const totalTextLength = sample.reduce((sum, seg) => sum + (seg.text?.length || 0), 0);
132 const avgTextLength = totalTextLength / sampleSize;
133
134 const sentenceEndingRegex = /[.!?\u3002\uff01\uff1f\u203c\u2047\u2048]\s*$/;
135 const sentenceEndingCount = sample.filter(seg =>
136 sentenceEndingRegex.test(seg.text?.trim() || '')
137 ).length;
138 const sentenceEndingRatio = sentenceEndingCount / sampleSize;
139
140 return {
141 segmentCount: transcript.length,
142 avgTextLength: Math.round(avgTextLength * 10) / 10,
143 sentenceEndingRatio: Math.round(sentenceEndingRatio * 100) / 100,
144 format: detectTranscriptFormat(transcript)
145 };
146}

Callers

nothing calls this directly

Calls 1

detectTranscriptFormatFunction · 0.85

Tested by

no test coverage detected