Classify source relatedness as data-quality advisories
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Package sourcerelatedness warns when cited source text does not mention a location occurrence.
|
||||
// Package sourcerelatedness reports advisory findings when cited source text does not mention a location occurrence.
|
||||
package sourcerelatedness
|
||||
|
||||
import (
|
||||
@@ -14,10 +14,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
Key = "extract/dnd/location-occurrences/source_relatedness"
|
||||
WarningReasonCode = "location_occurrence_not_near_source"
|
||||
OmittedReasonCode = "location_occurrence_relatedness_warnings_omitted"
|
||||
policy = "dnd.location_occurrences.validator.source_relatedness.v1"
|
||||
Key = "extract/dnd/location-occurrences/source_relatedness"
|
||||
ReasonCode = "location_occurrence_not_near_source"
|
||||
policy = "dnd.location_occurrences.validator.source_relatedness.v1"
|
||||
)
|
||||
|
||||
type Options struct{}
|
||||
@@ -56,9 +55,9 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
if shared.ContainsTokenSequence(citedTexts[index], occurrence.Name) {
|
||||
continue
|
||||
}
|
||||
warnings = append(warnings, contracts.Warning{Scope: fmt.Sprintf("occurrences[%d]", index), ReasonCode: WarningReasonCode, Message: fmt.Sprintf("Location occurrence name %s was not found in cited source text", diagnostics.Quote(occurrence.Name))})
|
||||
warnings = append(warnings, contracts.Warning{Scope: fmt.Sprintf("occurrences[%d]", index), ReasonCode: ReasonCode, Message: fmt.Sprintf("Location occurrence name %s was not found in cited source text", diagnostics.Quote(occurrence.Name))})
|
||||
}
|
||||
return contracts.ValidationResult{Approved: true, Warnings: diagnostics.LimitWarnings(warnings, "location_occurrences", OmittedReasonCode)}, nil
|
||||
return diagnostics.DataQualityResult(warnings)
|
||||
}
|
||||
func Spec() pipeline.ValidatorSpec {
|
||||
return pipeline.ValidatorSpec{Key: Key, ExecutionClass: contracts.ExecutionClassDeterministic}
|
||||
|
||||
Reference in New Issue
Block a user