Update the default postprocessing pipeline to run detect-overlaps twice
This commit is contained in:
@@ -90,6 +90,7 @@ func TestMergeWritesMergedOutputAndReport(t *testing.T) {
|
||||
"placeholder-merger",
|
||||
"detect-overlaps",
|
||||
"resolve-overlaps",
|
||||
"detect-overlaps",
|
||||
"autocorrect",
|
||||
"assign-ids",
|
||||
"validate-output",
|
||||
@@ -241,8 +242,8 @@ func TestMergeResolvesOverlapGroupsWithWordRuns(t *testing.T) {
|
||||
"end": 4,
|
||||
"text": "bob original",
|
||||
"words": [
|
||||
{"word": "bob", "start": 1.55, "end": 1.7},
|
||||
{"word": "reply", "start": 2.0, "end": 2.2}
|
||||
{"word": "bob", "start": 2.2, "end": 2.3},
|
||||
{"word": "reply", "start": 2.4, "end": 2.5}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -318,6 +319,97 @@ func TestMergeResolvesOverlapGroupsWithWordRuns(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeDetectsResidualOverlapsAfterResolution(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
inputA := writeJSONFile(t, dir, "a.json", `{
|
||||
"segments": [
|
||||
{
|
||||
"start": 1,
|
||||
"end": 4,
|
||||
"text": "alice residual",
|
||||
"words": [
|
||||
{"word": "alice", "start": 1.0, "end": 2.0}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`)
|
||||
inputB := writeJSONFile(t, dir, "b.json", `{
|
||||
"segments": [
|
||||
{
|
||||
"start": 1.5,
|
||||
"end": 3,
|
||||
"text": "bob residual",
|
||||
"words": [
|
||||
{"word": "bob", "start": 1.5, "end": 2.5}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`)
|
||||
speakers := writeYAMLFile(t, dir, "speakers.yml", `match:
|
||||
- speaker: Alice
|
||||
match: ["a.json"]
|
||||
- speaker: Bob
|
||||
match: ["b.json"]
|
||||
`)
|
||||
output := filepath.Join(dir, "merged.json")
|
||||
reportPath := filepath.Join(dir, "report.json")
|
||||
|
||||
err := executeMerge(
|
||||
"--input-file", inputA,
|
||||
"--input-file", inputB,
|
||||
"--speakers", speakers,
|
||||
"--output-file", output,
|
||||
"--report-file", reportPath,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("merge failed: %v", err)
|
||||
}
|
||||
|
||||
var transcript model.FinalTranscript
|
||||
readJSON(t, output, &transcript)
|
||||
if len(transcript.OverlapGroups) != 1 {
|
||||
t.Fatalf("overlap group count = %d, want 1", len(transcript.OverlapGroups))
|
||||
}
|
||||
group := transcript.OverlapGroups[0]
|
||||
if group.ID != 1 {
|
||||
t.Fatalf("group ID = %d, want 1", group.ID)
|
||||
}
|
||||
if group.Start != 1 || group.End != 2.5 {
|
||||
t.Fatalf("group bounds = %f-%f, want 1-2.5", group.Start, group.End)
|
||||
}
|
||||
wantRefs := []string{"word-run:1:1:1", "word-run:1:2:1"}
|
||||
if !equalStrings(group.Segments, wantRefs) {
|
||||
t.Fatalf("group refs = %v, want %v", group.Segments, wantRefs)
|
||||
}
|
||||
if !equalStrings(group.Speakers, []string{"Alice", "Bob"}) {
|
||||
t.Fatalf("group speakers = %v, want [Alice Bob]", group.Speakers)
|
||||
}
|
||||
for index, segment := range transcript.Segments {
|
||||
if segment.ID != index+1 {
|
||||
t.Fatalf("segment %d ID = %d, want %d", index, segment.ID, index+1)
|
||||
}
|
||||
if segment.OverlapGroupID != 1 {
|
||||
t.Fatalf("segment %d overlap group ID = %d, want 1", index, segment.OverlapGroupID)
|
||||
}
|
||||
if segment.SourceRef != wantRefs[index] {
|
||||
t.Fatalf("segment %d source_ref = %q, want %q", index, segment.SourceRef, wantRefs[index])
|
||||
}
|
||||
}
|
||||
|
||||
var rpt report.Report
|
||||
readJSON(t, reportPath, &rpt)
|
||||
detectMessages := make([]string, 0)
|
||||
for _, event := range rpt.Events {
|
||||
if event.Stage == "postprocessing" && event.Module == "detect-overlaps" {
|
||||
detectMessages = append(detectMessages, event.Message)
|
||||
}
|
||||
}
|
||||
wantMessages := []string{"detected 1 overlap group(s)", "detected 1 overlap group(s)"}
|
||||
if !equalStrings(detectMessages, wantMessages) {
|
||||
t.Fatalf("detect-overlaps messages = %v, want %v", detectMessages, wantMessages)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpeakerMatchingUsesFirstMatchingRuleCaseInsensitive(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
input := writeJSONFile(t, dir, "2026-04-19-Adam_Rakestraw.json", `{
|
||||
@@ -895,8 +987,8 @@ func TestMergeResolutionPreservesUntimedWordText(t *testing.T) {
|
||||
"end": 2,
|
||||
"text": "bob overlap",
|
||||
"words": [
|
||||
{"word": "bob", "start": 1.16, "end": 1.25},
|
||||
{"word": "overlap", "start": 1.3, "end": 1.5}
|
||||
{"word": "bob", "start": 1.6, "end": 1.7},
|
||||
{"word": "overlap", "start": 1.6, "end": 1.8}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user