Remove confidence scoring and refine correction prompts

This commit is contained in:
2026-11-11 17:05:52 +00:00
parent bbf89bb4f5
commit d155bf4cb3
92 changed files with 448 additions and 786 deletions

View File

@@ -15,7 +15,6 @@ func TestApplyProposalsApplyingOneProposal(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "gestures",
CorrectedText: "Jesters",
Confidence: 0.95,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 0, ModuleKey: "glossary", ModuleInstance: "glossary_1"},
},
@@ -42,7 +41,6 @@ func TestApplyProposalsApplyingMultipleProposalsInStableOrder(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "Hrank",
CorrectedText: "X",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 2, ModuleKey: "grammar", ModuleInstance: "grammar_1"},
},
@@ -51,7 +49,6 @@ func TestApplyProposalsApplyingMultipleProposalsInStableOrder(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "rank",
CorrectedText: "Hrank",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 1, ModuleKey: "homophones", ModuleInstance: "homophones"},
},
@@ -78,7 +75,6 @@ func TestApplyProposalsStaleProposalSkippedAfterEarlierChange(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "foo bar",
CorrectedText: "foo-bar",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 0, ModuleKey: "grammar", ModuleInstance: "grammar_1"},
},
@@ -87,7 +83,6 @@ func TestApplyProposalsStaleProposalSkippedAfterEarlierChange(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "foo bar",
CorrectedText: "foobar",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 1, ModuleKey: "grammar", ModuleInstance: "grammar_1"},
},
@@ -112,8 +107,8 @@ func TestApplyProposalsStaleProposalSkippedAfterEarlierChange(t *testing.T) {
func TestApplyProposalsRechecksBlankResultAfterEarlierDeletion(t *testing.T) {
transcript := &schema.Transcript{Segments: []schema.Segment{{ID: 1, Text: "a b"}}}
proposed := []EnrichedCorrectionProposal{
{CorrectionProposal: CorrectionProposal{TargetSegmentID: 1, OriginalText: "a", CorrectedText: "", Confidence: 1}, ProposalMetadata: ProposalMetadata{ProposalIndex: 0}},
{CorrectionProposal: CorrectionProposal{TargetSegmentID: 1, OriginalText: "b", CorrectedText: "", Confidence: 1}, ProposalMetadata: ProposalMetadata{ProposalIndex: 1}},
{CorrectionProposal: CorrectionProposal{TargetSegmentID: 1, OriginalText: "a", CorrectedText: ""}, ProposalMetadata: ProposalMetadata{ProposalIndex: 0}},
{CorrectionProposal: CorrectionProposal{TargetSegmentID: 1, OriginalText: "b", CorrectedText: ""}, ProposalMetadata: ProposalMetadata{ProposalIndex: 1}},
}
for _, candidate := range proposed {
if preview := PreviewProposalForSegment(&transcript.Segments[0], candidate.CorrectionProposal, ReplacementPolicyRequireUnique); !preview.Applicable {
@@ -137,7 +132,6 @@ func TestApplyProposalsMissingSegmentSkip(t *testing.T) {
TargetSegmentID: 999,
OriginalText: "hello",
CorrectedText: "hi",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 0, ModuleKey: "grammar", ModuleInstance: "grammar_1"},
},
@@ -161,7 +155,6 @@ func TestApplyProposalsRequireUniqueAmbiguousSkip(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "uh",
CorrectedText: "um",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 0, ModuleKey: "spoken_word", ModuleInstance: "spoken_word"},
},
@@ -185,7 +178,6 @@ func TestApplyProposalsReplaceAllMultipleReplacements(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "uh",
CorrectedText: "um",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 0, ModuleKey: "spoken_word", ModuleInstance: "spoken_word"},
},
@@ -214,7 +206,6 @@ func TestApplyProposalsNoMutationOfInputTranscript(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "hello",
CorrectedText: "hi",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 0, ModuleKey: "grammar", ModuleInstance: "grammar_1"},
},
@@ -243,7 +234,6 @@ func TestApplyProposalsSegmentMetadataPreservation(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "rank",
CorrectedText: "Hrank",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 0, ModuleKey: "glossary", ModuleInstance: "glossary_1"},
},
@@ -268,7 +258,6 @@ func TestApplyProposalsAppliedAndSkippedRecords(t *testing.T) {
TargetSegmentID: 1,
OriginalText: "hello",
CorrectedText: "hi",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 0, ModuleKey: "grammar", ModuleInstance: "grammar_1"},
},
@@ -277,7 +266,6 @@ func TestApplyProposalsAppliedAndSkippedRecords(t *testing.T) {
TargetSegmentID: 999,
OriginalText: "x",
CorrectedText: "y",
Confidence: 0.9,
},
ProposalMetadata: ProposalMetadata{ProposalIndex: 1, ModuleKey: "grammar", ModuleInstance: "grammar_1"},
},

View File

@@ -13,7 +13,6 @@ func TestPreviewProposalForSegmentRequireUniqueSuccess(t *testing.T) {
TargetSegmentID: 7,
OriginalText: "gestures",
CorrectedText: "Jesters",
Confidence: 0.9,
}
result := PreviewProposalForSegment(segment, proposal, ReplacementPolicyRequireUnique)
@@ -34,7 +33,6 @@ func TestPreviewProposalForSegmentRequireUniqueMissingOriginalText(t *testing.T)
TargetSegmentID: 7,
OriginalText: "gestures",
CorrectedText: "Jesters",
Confidence: 0.9,
}
result := PreviewProposalForSegment(segment, proposal, ReplacementPolicyRequireUnique)
@@ -52,7 +50,6 @@ func TestPreviewProposalForSegmentRequireUniqueAmbiguousOriginalText(t *testing.
TargetSegmentID: 7,
OriginalText: "rank",
CorrectedText: "Hrank",
Confidence: 0.9,
}
result := PreviewProposalForSegment(segment, proposal, ReplacementPolicyRequireUnique)
@@ -70,7 +67,6 @@ func TestPreviewProposalForSegmentReplaceAllSuccessMultipleOccurrences(t *testin
TargetSegmentID: 8,
OriginalText: "uh",
CorrectedText: "um",
Confidence: 0.9,
}
result := PreviewProposalForSegment(segment, proposal, ReplacementPolicyReplaceAll)
@@ -91,7 +87,6 @@ func TestPreviewProposalForSegmentReplaceAllMissingOriginalText(t *testing.T) {
TargetSegmentID: 8,
OriginalText: "uh",
CorrectedText: "um",
Confidence: 0.9,
}
result := PreviewProposalForSegment(segment, proposal, ReplacementPolicyReplaceAll)
@@ -109,7 +104,6 @@ func TestPreviewProposalForSegmentNoEffectReplacement(t *testing.T) {
TargetSegmentID: 8,
OriginalText: "hello",
CorrectedText: "hello",
Confidence: 0.9,
}
result := PreviewProposalForSegment(segment, proposal, ReplacementPolicyRequireUnique)
@@ -127,7 +121,6 @@ func TestPreviewProposalForSegmentAllowsEmptyCorrectedTextWhenSegmentRemainsNonE
TargetSegmentID: 8,
OriginalText: "uh ",
CorrectedText: "",
Confidence: 0.9,
}
result := PreviewProposalForSegment(segment, proposal, ReplacementPolicyRequireUnique)
@@ -140,7 +133,7 @@ func TestPreviewProposalForSegmentAllowsEmptyCorrectedTextWhenSegmentRemainsNonE
}
func TestPreviewProposalForSegmentWhitespaceSpan(t *testing.T) {
proposal := CorrectionProposal{TargetSegmentID: 8, OriginalText: " ", CorrectedText: " ", Confidence: 0.9}
proposal := CorrectionProposal{TargetSegmentID: 8, OriginalText: " ", CorrectedText: " "}
unique := PreviewProposalForSegment(&schema.Segment{ID: 8, Text: "hello world"}, proposal, ReplacementPolicyRequireUnique)
if !unique.Applicable || unique.CorrectedSegmentText != "hello world" || unique.ReplacementCount != 1 {
t.Fatalf("unexpected spacing preview: %+v", unique)
@@ -157,7 +150,7 @@ func TestPreviewProposalForSegmentWhitespaceSpan(t *testing.T) {
}
func TestPreviewProposalForSegmentRejectsEmptyOriginalText(t *testing.T) {
preview := PreviewProposalForSegment(&schema.Segment{ID: 8, Text: "hello"}, CorrectionProposal{TargetSegmentID: 8, OriginalText: "", CorrectedText: "x", Confidence: 0.9}, ReplacementPolicyRequireUnique)
preview := PreviewProposalForSegment(&schema.Segment{ID: 8, Text: "hello"}, CorrectionProposal{TargetSegmentID: 8, OriginalText: "", CorrectedText: "x"}, ReplacementPolicyRequireUnique)
if preview.Applicable || preview.SkipReason != SkipReasonInvalidProposal {
t.Fatalf("expected invalid empty original: %+v", preview)
}
@@ -169,7 +162,6 @@ func TestPreviewProposalForSegmentRejectsEmptyResultingSegment(t *testing.T) {
TargetSegmentID: 8,
OriginalText: "uh",
CorrectedText: "",
Confidence: 0.9,
}
result := PreviewProposalForSegment(segment, proposal, ReplacementPolicyRequireUnique)
@@ -188,7 +180,6 @@ func TestPreviewProposalForSegmentPreservesInputSegment(t *testing.T) {
TargetSegmentID: 9,
OriginalText: "rank",
CorrectedText: "Hrank",
Confidence: 0.9,
}
_ = PreviewProposalForSegment(segment, proposal, ReplacementPolicyReplaceAll)
@@ -205,7 +196,6 @@ func TestPreviewProposalForSegmentLiteralMatchingCaseSensitiveAndPunctuation(t *
TargetSegmentID: 10,
OriginalText: "world.",
CorrectedText: "earth.",
Confidence: 0.9,
}
punctuationResult := PreviewProposalForSegment(segment, punctuationProposal, ReplacementPolicyRequireUnique)
if !punctuationResult.Applicable {
@@ -219,7 +209,6 @@ func TestPreviewProposalForSegmentLiteralMatchingCaseSensitiveAndPunctuation(t *
TargetSegmentID: 10,
OriginalText: "hello",
CorrectedText: "Hi",
Confidence: 0.9,
}
caseMismatchResult := PreviewProposalForSegment(segment, caseMismatchProposal, ReplacementPolicyRequireUnique)
if caseMismatchResult.Applicable {

View File

@@ -6,10 +6,9 @@ import (
// 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"`
TargetSegmentID int `json:"id"`
OriginalText string `json:"original_text"`
CorrectedText string `json:"corrected_text"`
}
// ProposalMetadata is framework-enriched execution metadata for a proposal.
@@ -37,9 +36,6 @@ func (p CorrectionProposal) Validate() error {
if p.OriginalText == "" {
return fmt.Errorf("proposal original_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
}

View File

@@ -10,7 +10,6 @@ func TestCorrectionProposalValidate_Valid(t *testing.T) {
TargetSegmentID: 42,
OriginalText: "gestures",
CorrectedText: "Jesters",
Confidence: 0.95,
}
if err := proposal.Validate(); err != nil {
@@ -23,7 +22,6 @@ func TestCorrectionProposalValidate_InvalidEmptyOriginalText(t *testing.T) {
TargetSegmentID: 42,
OriginalText: "",
CorrectedText: "Jesters",
Confidence: 0.95,
}
err := proposal.Validate()
@@ -40,7 +38,6 @@ func TestCorrectionProposalValidate_AllowsEmptyCorrectedText(t *testing.T) {
TargetSegmentID: 42,
OriginalText: "gestures",
CorrectedText: "",
Confidence: 0.95,
}
if err := proposal.Validate(); err != nil {
@@ -49,35 +46,17 @@ func TestCorrectionProposalValidate_AllowsEmptyCorrectedText(t *testing.T) {
}
func TestCorrectionProposalValidate_AllowsWhitespaceOriginalText(t *testing.T) {
proposal := CorrectionProposal{TargetSegmentID: 42, OriginalText: " ", CorrectedText: " ", Confidence: 0.95}
proposal := CorrectionProposal{TargetSegmentID: 42, OriginalText: " ", CorrectedText: " "}
if err := proposal.Validate(); err != nil {
t.Fatalf("expected whitespace span to be valid, got %v", err)
}
}
func TestCorrectionProposalValidate_InvalidConfidence(t *testing.T) {
proposal := CorrectionProposal{
TargetSegmentID: 42,
OriginalText: "gestures",
CorrectedText: "Jesters",
Confidence: 1.1,
}
err := proposal.Validate()
if err == nil {
t.Fatal("expected validation error, got nil")
}
if err.Error() != "proposal confidence must be between 0.0 and 1.0" {
t.Fatalf("unexpected error: %v", err)
}
}
func TestCorrectionProposalValidate_InvalidSegmentID(t *testing.T) {
proposal := CorrectionProposal{
TargetSegmentID: 0,
OriginalText: "gestures",
CorrectedText: "Jesters",
Confidence: 0.95,
}
err := proposal.Validate()
@@ -147,7 +126,6 @@ func TestEnrichedCorrectionProposalJSONIncludesMetadata(t *testing.T) {
TargetSegmentID: 7,
OriginalText: "teh",
CorrectedText: "the",
Confidence: 0.8,
},
ProposalMetadata: ProposalMetadata{
ProposalIndex: 1,
@@ -162,7 +140,7 @@ func TestEnrichedCorrectionProposalJSONIncludesMetadata(t *testing.T) {
t.Fatalf("marshal failed: %v", err)
}
const expected = `{"id":7,"original_text":"teh","corrected_text":"the","confidence":0.8,"proposal_index":1,"module_key":"grammar","module_instance":"grammar_1","section_index":3}`
const expected = `{"id":7,"original_text":"teh","corrected_text":"the","proposal_index":1,"module_key":"grammar","module_instance":"grammar_1","section_index":3}`
if string(b) != expected {
t.Fatalf("unexpected json\nexpected: %s\nactual: %s", expected, string(b))
}

View File

@@ -18,8 +18,7 @@
"module_instance": "homophones",
"id": 1,
"original_text": "rank",
"corrected_text": "Hrank",
"confidence": 0.9
"corrected_text": "Hrank"
}
]
}

View File

@@ -27,8 +27,7 @@
"module_instance": "glossary_1",
"id": 2,
"original_text": "rank",
"corrected_text": "Hrank",
"confidence": 0.9
"corrected_text": "Hrank"
}
]
}

View File

@@ -18,8 +18,7 @@
"module_instance": "grammar_1",
"id": 99,
"original_text": "hello",
"corrected_text": "hi",
"confidence": 0.9
"corrected_text": "hi"
}
]
}

View File

@@ -25,8 +25,7 @@
"module_instance": "grammar_1",
"id": 1,
"original_text": "foo bar",
"corrected_text": "foo-bar",
"confidence": 0.9
"corrected_text": "foo-bar"
},
{
"proposal_index": 1,
@@ -34,8 +33,7 @@
"module_instance": "grammar_1",
"id": 1,
"original_text": "foo bar",
"corrected_text": "foobar",
"confidence": 0.9
"corrected_text": "foobar"
},
{
"proposal_index": 2,
@@ -43,8 +41,7 @@
"module_instance": "homophones",
"id": 1,
"original_text": "rank",
"corrected_text": "Hrank",
"confidence": 0.9
"corrected_text": "Hrank"
},
{
"proposal_index": 3,
@@ -52,8 +49,7 @@
"module_instance": "grammar_1",
"id": 99,
"original_text": "x",
"corrected_text": "y",
"confidence": 0.9
"corrected_text": "y"
},
{
"proposal_index": 4,
@@ -61,8 +57,7 @@
"module_instance": "spoken_word",
"id": 2,
"original_text": "hello",
"corrected_text": "hello",
"confidence": 0.9
"corrected_text": "hello"
}
]
}

View File

@@ -18,8 +18,7 @@
"module_instance": "grammar_1",
"id": 1,
"original_text": "bar",
"corrected_text": "BAR",
"confidence": 0.9
"corrected_text": "BAR"
},
{
"proposal_index": 1,
@@ -27,8 +26,7 @@
"module_instance": "grammar_1",
"id": 1,
"original_text": "foo",
"corrected_text": "FOO",
"confidence": 0.9
"corrected_text": "FOO"
}
]
}

View File

@@ -18,8 +18,7 @@
"module_instance": "spoken_word",
"id": 1,
"original_text": "uh",
"corrected_text": "um",
"confidence": 0.9
"corrected_text": "um"
}
]
}

View File

@@ -18,8 +18,7 @@
"module_instance": "spoken_word",
"id": 1,
"original_text": "ha",
"corrected_text": "ho",
"confidence": 0.9
"corrected_text": "ho"
}
]
}

View File

@@ -18,8 +18,7 @@
"module_instance": "glossary_1",
"id": 1,
"original_text": "gestures",
"corrected_text": "Jesters",
"confidence": 0.95
"corrected_text": "Jesters"
}
]
}

View File

@@ -18,8 +18,7 @@
"module_instance": "grammar_1",
"id": 1,
"original_text": "foo bar",
"corrected_text": "foo-bar",
"confidence": 0.9
"corrected_text": "foo-bar"
},
{
"proposal_index": 1,
@@ -27,8 +26,7 @@
"module_instance": "grammar_1",
"id": 1,
"original_text": "foo bar",
"corrected_text": "foobar",
"confidence": 0.9
"corrected_text": "foobar"
}
]
}