Validate correction repair through the processing command
This commit is contained in:
@@ -156,7 +156,7 @@ func ValidateProtectedTerms(req Request) (Result, error) {
|
||||
continue
|
||||
}
|
||||
preview := previewForEvidence(req, segment, c.CorrectionProposal)
|
||||
if preview.Applicable {
|
||||
if preview.Applicable || (req.IndependentEvidence && preview.SkipReason == proposals.SkipReasonEmptyResultingText) {
|
||||
if glossaryStage {
|
||||
// A correction span may sit inside a longer exempt name.
|
||||
reason = vocab.violationReason(segment.Text, preview.CorrectedSegmentText)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package validators
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -95,32 +96,35 @@ func (v ProtectedVocabulary) occurrences(text string) []protectedOccurrence {
|
||||
}
|
||||
|
||||
func validateIdentityPreservation(beforeByID, afterByID map[glossary.Identity][]protectedOccurrence) string {
|
||||
var spellings []string
|
||||
for identity, beforeItems := range beforeByID {
|
||||
if len(afterByID[identity]) < len(beforeItems) {
|
||||
return "proposal may alter protected glossary terminology"
|
||||
if len(afterByID[identity]) < len(beforeItems) && len(beforeItems) > 0 {
|
||||
spellings = append(spellings, beforeItems[0].canonical)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
return protectedSpellingMessage(spellings)
|
||||
}
|
||||
|
||||
func validateCapitalizationTransitions(beforeByID, afterByID map[glossary.Identity][]protectedOccurrence) string {
|
||||
var spellings []string
|
||||
for identity, afterItems := range afterByID {
|
||||
beforeItems := beforeByID[identity]
|
||||
for i, afterItem := range afterItems {
|
||||
if i >= len(beforeItems) {
|
||||
if i >= len(beforeItems) || afterItem.text == beforeItems[i].text || afterItem.text == afterItem.canonical {
|
||||
continue
|
||||
}
|
||||
beforeItem := beforeItems[i]
|
||||
if afterItem.text == beforeItem.text {
|
||||
continue
|
||||
}
|
||||
if afterItem.text == afterItem.canonical {
|
||||
continue
|
||||
}
|
||||
return "proposal may alter protected glossary terminology"
|
||||
spellings = append(spellings, afterItem.canonical)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
return protectedSpellingMessage(spellings)
|
||||
}
|
||||
|
||||
func protectedSpellingMessage(spellings []string) string {
|
||||
if len(spellings) == 0 {
|
||||
return ""
|
||||
}
|
||||
sort.Strings(spellings)
|
||||
return fmt.Sprintf("proposal may alter protected glossary spelling %q", spellings[0])
|
||||
}
|
||||
|
||||
// preservesRepeatedIdentities permits a spoken-word proposal to reduce repeated
|
||||
|
||||
Reference in New Issue
Block a user