Skip application for sections without approved edits
This commit is contained in:
@@ -254,6 +254,12 @@ func transcriptFromSections(sections []chunking.Section) *schema.Transcript {
|
||||
// applyWithinSections leaves section membership and initial metadata unchanged.
|
||||
// Approved proposals are applied only to their identified section.
|
||||
func applyWithinSections(sections []chunking.Section, approved []proposals.EnrichedCorrectionProposal, policy proposals.ReplacementPolicy, vocabulary validators.ProtectedVocabulary, allowRepetitionCleanup bool) ([]chunking.Section, []proposals.AppliedChange, []proposals.SkippedChange, []int, error) {
|
||||
applied := make([]proposals.AppliedChange, 0)
|
||||
skipped := make([]proposals.SkippedChange, 0)
|
||||
appliedBySection := make([]int, len(sections))
|
||||
if len(approved) == 0 {
|
||||
return sections, applied, skipped, appliedBySection, nil
|
||||
}
|
||||
bySection := make(map[int][]proposals.EnrichedCorrectionProposal, len(sections))
|
||||
known := make(map[int]struct{}, len(sections))
|
||||
for _, section := range sections {
|
||||
@@ -270,11 +276,12 @@ func applyWithinSections(sections []chunking.Section, approved []proposals.Enric
|
||||
}
|
||||
updated := make([]chunking.Section, len(sections))
|
||||
copy(updated, sections)
|
||||
applied := make([]proposals.AppliedChange, 0)
|
||||
skipped := make([]proposals.SkippedChange, 0)
|
||||
appliedBySection := make([]int, len(sections))
|
||||
for i, section := range sections {
|
||||
result := proposals.ApplyProposals(transcriptFromSection(section), bySection[section.Index], policy, func(before, after string) bool { return vocabulary.AllowsChange(before, after, allowRepetitionCleanup) })
|
||||
candidates := bySection[section.Index]
|
||||
if len(candidates) == 0 {
|
||||
continue
|
||||
}
|
||||
result := proposals.ApplyProposals(transcriptFromSection(section), candidates, policy, func(before, after string) bool { return vocabulary.AllowsChange(before, after, allowRepetitionCleanup) })
|
||||
updated[i].Segments = result.Transcript.Segments
|
||||
applied = append(applied, result.Applied...)
|
||||
skipped = append(skipped, result.Skipped...)
|
||||
|
||||
Reference in New Issue
Block a user