Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const ENGLISH_CONTRACTION_MAP: Record<string, string> = {
im: "i'm",
ive: "i've",
ill: "i'll",
id: "i'd",
dont: "don't",
cant: "can't",
wont: "won't",
Expand All @@ -28,7 +27,7 @@ const ENGLISH_CONTRACTION_MAP: Record<string, string> = {
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;
Expand Down
7 changes: 6 additions & 1 deletion tests/e2e/coverage-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/full.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 8 additions & 0 deletions tests/grammar/V2EnglishRules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading