Align prompts and strengthen validation context
This commit is contained in:
@@ -87,3 +87,29 @@ func TestValidateProtectedTermsGlossaryStageAllowsProtectedTermSwap(t *testing.T
|
||||
t.Fatalf("expected approval for glossary-stage protected term correction, got %+v", res.Decisions)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProtectedNameRepetitionRequiresSurvivingIdentityAndSpokenWordScope(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name, module, before, original, replacement string
|
||||
allowed bool
|
||||
}{
|
||||
{"whole repetition", "spoken_word", "Jesters Jesters arrived", "Jesters Jesters", "Jesters", true},
|
||||
{"span deletion", "spoken_word", "Jesters, Jesters arrived", "Jesters, ", "", true},
|
||||
{"last reference", "spoken_word", "Jesters arrived", "Jesters ", "", false},
|
||||
{"different identity", "spoken_word", "Jesters Jesters arrived", "Jesters Jesters", "Lyra", false},
|
||||
{"spelling degraded", "spoken_word", "Jesters Jesters arrived", "Jesters Jesters", "jestERS", false},
|
||||
{"grammar unchanged", "grammar", "Jesters Jesters arrived", "Jesters Jesters", "Jesters", false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
req := Request{ModuleKey: tc.module, ReplacementPolicy: proposals.ReplacementPolicyRequireUnique,
|
||||
WorkingTranscript: &schema.Transcript{Segments: []schema.Segment{{ID: 1, Text: tc.before}}},
|
||||
Glossary: &schema.Glossary{Entries: []schema.GlossaryEntry{{Name: "Jesters"}, {Name: "Lyra"}}},
|
||||
CandidateProposal: []proposals.EnrichedCorrectionProposal{{CorrectionProposal: proposals.CorrectionProposal{TargetSegmentID: 1, OriginalText: tc.original, CorrectedText: tc.replacement, Confidence: 1}}},
|
||||
}
|
||||
result, err := ValidateProtectedTerms(req, false)
|
||||
if err != nil || len(result.Decisions) != 1 || result.Decisions[0].Approved != tc.allowed {
|
||||
t.Fatalf("result=%+v err=%v", result, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user