Add correction proposal models
This commit is contained in:
49
internal/framework/proposals/proposal.go
Normal file
49
internal/framework/proposals/proposal.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package proposals
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CorrectionProposal is the base proposal emitted by correction modules.
|
||||
type CorrectionProposal struct {
|
||||
TargetSegmentID int `json:"id"`
|
||||
OriginalText string `json:"original_text"`
|
||||
CorrectedText string `json:"corrected_text"`
|
||||
Confidence float64 `json:"confidence"`
|
||||
}
|
||||
|
||||
// ProposalMetadata is framework-enriched execution metadata for a proposal.
|
||||
type ProposalMetadata struct {
|
||||
ProposalIndex int `json:"proposal_index"`
|
||||
ModuleKey string `json:"module_key"`
|
||||
ModuleInstance string `json:"module_instance"`
|
||||
SectionIndex *int `json:"section_index,omitempty"`
|
||||
}
|
||||
|
||||
// EnrichedCorrectionProposal combines module-emitted proposal data with
|
||||
// framework execution metadata.
|
||||
type EnrichedCorrectionProposal struct {
|
||||
CorrectionProposal
|
||||
ProposalMetadata
|
||||
}
|
||||
|
||||
// Validate checks only basic structural integrity of the proposal.
|
||||
// Semantic checks (staleness, span presence, replacement behavior) are handled
|
||||
// by later proposal preview/application and validator phases.
|
||||
func (p CorrectionProposal) Validate() error {
|
||||
if p.TargetSegmentID <= 0 {
|
||||
return fmt.Errorf("proposal id must be positive")
|
||||
}
|
||||
if strings.TrimSpace(p.OriginalText) == "" {
|
||||
return fmt.Errorf("proposal original_text must not be empty")
|
||||
}
|
||||
if strings.TrimSpace(p.CorrectedText) == "" {
|
||||
return fmt.Errorf("proposal corrected_text must not be empty")
|
||||
}
|
||||
if p.Confidence < 0.0 || p.Confidence > 1.0 {
|
||||
return fmt.Errorf("proposal confidence must be between 0.0 and 1.0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user