From 1922a2c1d696ff951f34533b611a0cc45333c5cc Mon Sep 17 00:00:00 2001 From: Repo Assist Date: Sat, 21 Feb 2026 13:03:39 +0000 Subject: [PATCH] Fix pluralizer incorrectly singularizing words ending in '-ases' (e.g. 'purchases' -> 'purchasis') Add 'ase'/'ases' suffix rule before the 'sis'/'ses' rule so that words like 'purchases', 'cases', 'phases', 'phrases' correctly singularize to 'purchase', 'case', 'phase', 'phrase' respectively. Add 'oasis'/'oases' to the special words list to preserve the correct singularization of 'oases' -> 'oasis', which would otherwise be affected by the new 'ase'/'ases' rule. Fixes #1508 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/FSharp.Data.Runtime.Utilities/Pluralizer.fs | 2 ++ tests/FSharp.Data.Core.Tests/Pluralizer.fs | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/FSharp.Data.Runtime.Utilities/Pluralizer.fs b/src/FSharp.Data.Runtime.Utilities/Pluralizer.fs index ebd505a18..4ca702bbc 100644 --- a/src/FSharp.Data.Runtime.Utilities/Pluralizer.fs +++ b/src/FSharp.Data.Runtime.Utilities/Pluralizer.fs @@ -50,6 +50,7 @@ let private tables = "cis", "ces" "us", "uses" + "ase", "ases" "sis", "ses" "xis", "xes" @@ -148,6 +149,7 @@ let private tables = "murex", "murecis", "" "mythos", "mythos", "mythoi" "news", "", "" + "oasis", "oases", "" "octopus", "octopuses", "octopodes" "ovum", "ova", "" "ox", "ox", "oxen" diff --git a/tests/FSharp.Data.Core.Tests/Pluralizer.fs b/tests/FSharp.Data.Core.Tests/Pluralizer.fs index cbe07d2d2..b266bc58e 100644 --- a/tests/FSharp.Data.Core.Tests/Pluralizer.fs +++ b/tests/FSharp.Data.Core.Tests/Pluralizer.fs @@ -202,6 +202,21 @@ let ``Roundtrip consistency for common words`` () = word <> "aircraft" && word <> "series" then backToSingular |> should equal word +[] +let ``Purchases singularizes correctly - regression test for issue 1508`` () = + // Previously "purchases" was incorrectly singularized to "purchasis" + // due to the "sis"/"ses" suffix rule matching words ending in "ses" + toSingular "purchases" |> should equal "purchase" + toPlural "purchase" |> should equal "purchases" + // Other "-ase" words should also work correctly + toSingular "cases" |> should equal "case" + toSingular "phases" |> should equal "phase" + toSingular "phrases" |> should equal "phrase" + toSingular "vases" |> should equal "vase" + // "oases" should still correctly singularize to "oasis" (via special word list) + toSingular "oases" |> should equal "oasis" + toPlural "oasis" |> should equal "oases" + [] let ``Performance with repeated calls`` () = // Test that repeated calls with same input work correctly (testing lazy initialization)