Derive independent glossary context and protection
This commit is contained in:
@@ -43,6 +43,7 @@ func ApplyProposals(
|
||||
transcript *schema.Transcript,
|
||||
proposals []EnrichedCorrectionProposal,
|
||||
policy ReplacementPolicy,
|
||||
allowsChange func(before, after string) bool,
|
||||
) ApplyResult {
|
||||
working := cloneTranscript(transcript)
|
||||
ordered := sortProposalsByIndex(proposals)
|
||||
@@ -68,6 +69,11 @@ func ApplyProposals(
|
||||
continue
|
||||
}
|
||||
|
||||
if allowsChange != nil && !allowsChange(working.Segments[segmentIdx].Text, preview.CorrectedSegmentText) {
|
||||
skipped = append(skipped, newSkippedChange(proposal, SkipReasonProtectedTerm))
|
||||
continue
|
||||
}
|
||||
|
||||
working.Segments[segmentIdx].Text = preview.CorrectedSegmentText
|
||||
applied = append(applied, AppliedChange{
|
||||
ProposalIndex: proposal.ProposalIndex,
|
||||
@@ -149,6 +155,8 @@ func skipReasonMessage(reason ProposalSkipReason) string {
|
||||
return "original_text and corrected_text are identical"
|
||||
case SkipReasonEmptyResultingText:
|
||||
return "proposal would leave the segment empty"
|
||||
case SkipReasonProtectedTerm:
|
||||
return "proposal may alter protected glossary terminology"
|
||||
case SkipReasonInvalidProposal:
|
||||
return "proposal failed structural or policy validation"
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user