diff --git a/reversal/multiplier.go b/reversal/multiplier.go index d621f71..031b891 100644 --- a/reversal/multiplier.go +++ b/reversal/multiplier.go @@ -139,9 +139,10 @@ func (m *Multiplier) applyVerbTransform(tokens []Token, vi int, targetTense stri newForm = preserveCase(tok.Raw, newForm) result[vi] = Token{ - Raw: newForm, - Lower: strings.ToLower(newForm), - Type: TokenVerb, + Raw: newForm, + Lower: strings.ToLower(newForm), + Type: TokenVerb, + Confidence: 1.0, VerbInfo: VerbMatch{ Base: base, Tense: targetTense, @@ -189,9 +190,10 @@ func (m *Multiplier) applyNounTransformOnTokens(tokens []Token, ni int) []Token newForm = preserveCase(tok.Raw, newForm) result[ni] = Token{ - Raw: newForm, - Lower: strings.ToLower(newForm), - Type: TokenNoun, + Raw: newForm, + Lower: strings.ToLower(newForm), + Type: TokenNoun, + Confidence: 1.0, NounInfo: NounMatch{ Base: base, Plural: newPlural, diff --git a/reversal/multiplier_test.go b/reversal/multiplier_test.go index 3a2a339..24743e1 100644 --- a/reversal/multiplier_test.go +++ b/reversal/multiplier_test.go @@ -66,3 +66,44 @@ func TestMultiplier_Expand_Deterministic(t *testing.T) { } } } + +func TestMultiplier_Expand_DualClass(t *testing.T) { + svc, _ := i18n.New() + i18n.SetDefault(svc) + m := NewMultiplier() + + // "the commit" — commit is noun, should still produce variants + variants := m.Expand("the commit") + if len(variants) < 2 { + t.Errorf("Expand('the commit') returned %d variants, want >= 2", len(variants)) + } + + // Should have at least original + plural toggle + found := false + for _, v := range variants { + if v == "the commits" { + found = true + } + } + if !found { + t.Errorf("Expected 'the commits' variant, got: %v", variants) + } +} + +func TestMultiplier_TransformedTokenConfidence(t *testing.T) { + svc, _ := i18n.New() + i18n.SetDefault(svc) + m := NewMultiplier() + + // Verify that transformed tokens have Confidence set + tokens := m.tokeniser.Tokenise("Delete the branch") + pastTokens := m.applyVerbTransform(tokens, 0, "past") + if pastTokens[0].Confidence == 0 { + t.Error("Verb-transformed token has zero Confidence, want 1.0") + } + + pluralTokens := m.applyNounTransformOnTokens(tokens, 2) + if pluralTokens[2].Confidence == 0 { + t.Error("Noun-transformed token has zero Confidence, want 1.0") + } +}