Retain repair diagnostics and correction lineage
This commit is contained in:
@@ -3,6 +3,7 @@ package validators
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/modulecatalog"
|
||||
@@ -104,7 +105,7 @@ func (v NonEmptyResultingSegmentValidator) Validate(_ context.Context, req Reque
|
||||
decisions = append(decisions, approval(c.ProposalIndex))
|
||||
continue
|
||||
}
|
||||
preview := proposals.PreviewProposalForSegment(&segment, c.CorrectionProposal, req.ReplacementPolicy)
|
||||
preview := previewForEvidence(req, &segment, c.CorrectionProposal)
|
||||
if preview.SkipReason == proposals.SkipReasonEmptyResultingText {
|
||||
decisions = append(decisions, rejection(c.ProposalIndex, ReasonEmptyResultingText, "proposal would leave the segment empty"))
|
||||
continue
|
||||
@@ -154,7 +155,7 @@ func ValidateProtectedTerms(req Request) (Result, error) {
|
||||
if segment.ID != c.TargetSegmentID {
|
||||
continue
|
||||
}
|
||||
preview := proposals.PreviewProposalForSegment(segment, c.CorrectionProposal, req.ReplacementPolicy)
|
||||
preview := previewForEvidence(req, segment, c.CorrectionProposal)
|
||||
if preview.Applicable {
|
||||
if glossaryStage {
|
||||
// A correction span may sit inside a longer exempt name.
|
||||
@@ -177,3 +178,10 @@ func ValidateProtectedTerms(req Request) (Result, error) {
|
||||
}
|
||||
return Result{ValidatorName: "protected_terms", Decisions: decisions}, nil
|
||||
}
|
||||
|
||||
func previewForEvidence(req Request, segment *schema.Segment, correction proposals.CorrectionProposal) proposals.SegmentPreviewResult {
|
||||
if req.IndependentEvidence && (math.IsNaN(correction.Confidence) || correction.Confidence < 0 || correction.Confidence > 1) {
|
||||
correction.Confidence = 0.5
|
||||
}
|
||||
return proposals.PreviewProposalForSegment(segment, correction, req.ReplacementPolicy)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user