Bugfix in the coalesce module
This commit is contained in:
@@ -165,6 +165,119 @@ func TestApplyDropsFillerCategoryFromMergedSameSpeakerRun(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyMergesSameSpeakerBackchannelIntoDerivedRun(t *testing.T) {
|
||||
first := segment("zach.json", 110, "Zach", 7811.778, 7812.478, "That makes sense.")
|
||||
first.Categories = []string{"backchannel"}
|
||||
second := model.Segment{
|
||||
Source: "zach.json",
|
||||
SourceRef: "coalesce:347",
|
||||
DerivedFrom: []string{"zach.json#111", "zach.json#112"},
|
||||
Speaker: "Zach",
|
||||
Start: 7812.498,
|
||||
End: 7824.045,
|
||||
Text: "So, like, I'm above the silence field.",
|
||||
}
|
||||
|
||||
got, summary := Apply(model.MergedTranscript{Segments: []model.Segment{first, second}}, 3)
|
||||
if summary.OriginalSegmentsMerged != 2 || summary.CoalescedSegments != 1 {
|
||||
t.Fatalf("summary = %#v", summary)
|
||||
}
|
||||
if len(got.Segments) != 1 {
|
||||
t.Fatalf("segment count = %d, want 1", len(got.Segments))
|
||||
}
|
||||
if got.Segments[0].Text != "That makes sense. So, like, I'm above the silence field." {
|
||||
t.Fatalf("text = %q", got.Segments[0].Text)
|
||||
}
|
||||
if got.Segments[0].SourceRef != "coalesce:1" {
|
||||
t.Fatalf("source_ref = %q, want coalesce:1", got.Segments[0].SourceRef)
|
||||
}
|
||||
if !reflect.DeepEqual(got.Segments[0].DerivedFrom, []string{"zach.json#110", "coalesce:347"}) {
|
||||
t.Fatalf("derived_from = %v", got.Segments[0].DerivedFrom)
|
||||
}
|
||||
if got.Segments[0].Categories != nil {
|
||||
t.Fatalf("categories = %v, want nil", got.Segments[0].Categories)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyMergesSameSpeakerFillerIntoDerivedRun(t *testing.T) {
|
||||
first := segment("zach.json", 110, "Zach", 1, 1.5, "um")
|
||||
first.Categories = []string{"filler"}
|
||||
second := model.Segment{
|
||||
Source: "zach.json",
|
||||
SourceRef: "coalesce:12",
|
||||
DerivedFrom: []string{"zach.json#111", "zach.json#112"},
|
||||
Speaker: "Zach",
|
||||
Start: 1.6,
|
||||
End: 4,
|
||||
Text: "next thought",
|
||||
}
|
||||
|
||||
got, summary := Apply(model.MergedTranscript{Segments: []model.Segment{first, second}}, 3)
|
||||
if summary.OriginalSegmentsMerged != 2 || summary.CoalescedSegments != 1 {
|
||||
t.Fatalf("summary = %#v", summary)
|
||||
}
|
||||
if len(got.Segments) != 1 {
|
||||
t.Fatalf("segment count = %d, want 1", len(got.Segments))
|
||||
}
|
||||
if got.Segments[0].Text != "um next thought" {
|
||||
t.Fatalf("text = %q", got.Segments[0].Text)
|
||||
}
|
||||
if !reflect.DeepEqual(got.Segments[0].DerivedFrom, []string{"zach.json#110", "coalesce:12"}) {
|
||||
t.Fatalf("derived_from = %v", got.Segments[0].DerivedFrom)
|
||||
}
|
||||
if got.Segments[0].Categories != nil {
|
||||
t.Fatalf("categories = %v, want nil", got.Segments[0].Categories)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyUsesSkippedBackchannelToSeedNextSameSpeakerRun(t *testing.T) {
|
||||
mike := segment("mike.json", 367, "Mike", 7803.57, 7810.719, "It's very easy to notice.")
|
||||
backchannel := segment("zach.json", 110, "Zach", 7811.778, 7812.478, "That makes sense.")
|
||||
backchannel.Categories = []string{"backchannel"}
|
||||
next := segment("zach.json", 111, "Zach", 7812.498, 7820, "So, like, next thought.")
|
||||
|
||||
got, summary := Apply(model.MergedTranscript{Segments: []model.Segment{mike, backchannel, next}}, 3)
|
||||
if summary.OriginalSegmentsMerged != 2 || summary.CoalescedSegments != 1 {
|
||||
t.Fatalf("summary = %#v", summary)
|
||||
}
|
||||
if len(got.Segments) != 2 {
|
||||
t.Fatalf("segment count = %d, want 2", len(got.Segments))
|
||||
}
|
||||
if got.Segments[0].Text != "It's very easy to notice." {
|
||||
t.Fatalf("first text = %q", got.Segments[0].Text)
|
||||
}
|
||||
if got.Segments[1].Speaker != "Zach" || got.Segments[1].Text != "That makes sense. So, like, next thought." {
|
||||
t.Fatalf("second segment = %#v", got.Segments[1])
|
||||
}
|
||||
if !reflect.DeepEqual(got.Segments[1].DerivedFrom, []string{"zach.json#110", "zach.json#111"}) {
|
||||
t.Fatalf("derived_from = %v", got.Segments[1].DerivedFrom)
|
||||
}
|
||||
if got.Segments[1].Categories != nil {
|
||||
t.Fatalf("categories = %v, want nil", got.Segments[1].Categories)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyUsesSkippedFillerToSeedNextSameSpeakerRun(t *testing.T) {
|
||||
alice := segment("alice.json", 0, "Alice", 1, 2, "first")
|
||||
filler := segment("bob.json", 0, "Bob", 2.1, 2.3, "um")
|
||||
filler.Categories = []string{"filler"}
|
||||
bob := segment("bob.json", 1, "Bob", 2.4, 4, "actual thought")
|
||||
|
||||
got, summary := Apply(model.MergedTranscript{Segments: []model.Segment{alice, filler, bob}}, 3)
|
||||
if summary.OriginalSegmentsMerged != 2 || summary.CoalescedSegments != 1 {
|
||||
t.Fatalf("summary = %#v", summary)
|
||||
}
|
||||
if len(got.Segments) != 2 {
|
||||
t.Fatalf("segment count = %d, want 2", len(got.Segments))
|
||||
}
|
||||
if got.Segments[1].Text != "um actual thought" {
|
||||
t.Fatalf("second text = %q", got.Segments[1].Text)
|
||||
}
|
||||
if got.Segments[1].Categories != nil {
|
||||
t.Fatalf("categories = %v, want nil", got.Segments[1].Categories)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplySkipsDifferentSpeakerBackchannelAsMergeBlocker(t *testing.T) {
|
||||
first := segment("a.json", 0, "Alice", 1, 2, "first")
|
||||
backchannel := segment("b.json", 0, "Bob", 2.2, 2.5, "yeah")
|
||||
|
||||
Reference in New Issue
Block a user