From 01b44e9b684d5a25940577f304c315b4b2c406df Mon Sep 17 00:00:00 2001 From: Bartosz Tomczyk Date: Sat, 8 Aug 2026 10:03:31 +0200 Subject: [PATCH] Preserve ambiguous id forms --- .../EnglishContractionNormalizationRule.ts | 3 +-- tests/e2e/coverage-matrix.json | 7 ++++++- tests/e2e/full.e2e.test.ts | 4 ++++ tests/grammar/V2EnglishRules.test.ts | 8 ++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/core/domain/grammar/implementations/EnglishContractionNormalizationRule.ts b/src/core/domain/grammar/implementations/EnglishContractionNormalizationRule.ts index 34fa6efb..b786b641 100644 --- a/src/core/domain/grammar/implementations/EnglishContractionNormalizationRule.ts +++ b/src/core/domain/grammar/implementations/EnglishContractionNormalizationRule.ts @@ -10,7 +10,6 @@ const ENGLISH_CONTRACTION_MAP: Record = { im: "i'm", ive: "i've", ill: "i'll", - id: "i'd", dont: "don't", cant: "can't", wont: "won't", @@ -28,7 +27,7 @@ const ENGLISH_CONTRACTION_MAP: Record = { wouldnt: "wouldn't", mustnt: "mustn't", }; -const FORCE_PRONOUN_I_PREFIX = new Set(["im", "ive", "ill", "id"]); +const FORCE_PRONOUN_I_PREFIX = new Set(["im", "ive", "ill"]); export class EnglishContractionNormalizationRule implements GrammarRule { readonly id = "englishContractionNormalization" as const; diff --git a/tests/e2e/coverage-matrix.json b/tests/e2e/coverage-matrix.json index 2e0b0a9c..e50f6978 100644 --- a/tests/e2e/coverage-matrix.json +++ b/tests/e2e/coverage-matrix.json @@ -921,7 +921,7 @@ }, { "id": "grammar_english_contractions", - "description": "English-only grammar rule normalizes common contractions with case preservation.", + "description": "English-only grammar rule normalizes common contractions with case preservation while leaving ambiguous id forms unchanged.", "coverage": [ { "layer": "e2e-full", @@ -932,6 +932,11 @@ "layer": "unit", "file": "tests/grammar/V2EnglishRules.test.ts", "test": "normalizes contraction forms and preserves case" + }, + { + "layer": "unit", + "file": "tests/grammar/V2EnglishRules.test.ts", + "test": "preserves ambiguous id forms" } ] }, diff --git a/tests/e2e/full.e2e.test.ts b/tests/e2e/full.e2e.test.ts index 96e097ef..c6b21dd2 100644 --- a/tests/e2e/full.e2e.test.ts +++ b/tests/e2e/full.e2e.test.ts @@ -5639,6 +5639,10 @@ describeE2E(`Extension E2E Test [${BROWSER_TYPE}]`, () => { await typeInInput(page, selector, "ready"); await waitForInputContentEqual(page, selector, "I'm ready", browserTimeout(5000, 9000)); + await clearInputContent(page, selector); + await typeInInput(page, selector, "ID "); + await waitForInputContentEqual(page, selector, "ID ", browserTimeout(5000, 9000)); + await clearInputContent(page, selector); await typeInInput(page, selector, "teh "); await waitForInputContentEqual(page, selector, "the ", browserTimeout(5000, 9000)); diff --git a/tests/grammar/V2EnglishRules.test.ts b/tests/grammar/V2EnglishRules.test.ts index ca5585f8..96d30a51 100644 --- a/tests/grammar/V2EnglishRules.test.ts +++ b/tests/grammar/V2EnglishRules.test.ts @@ -102,6 +102,14 @@ describe("V2 english grammar rules", () => { }); }); + test("preserves ambiguous id forms", () => { + const rule = new EnglishContractionNormalizationRule(); + + expect(rule.apply(context("ID ", { lang: "en_US", inputAction: "insert" }))).toBeNull(); + expect(rule.apply(context("Id ", { lang: "en_US", inputAction: "insert" }))).toBeNull(); + expect(rule.apply(context("id ", { lang: "en_US", inputAction: "insert" }))).toBeNull(); + }); + test("does not normalize on delete action or non-English context", () => { const rule = new EnglishContractionNormalizationRule(); expect(rule.apply(context("im ", { lang: "en_US", inputAction: "delete" }))).toBeNull();