Skip to content

Commit

Permalink
generalize for words ending with "men"
Browse files Browse the repository at this point in the history
  • Loading branch information
ProDivNet committed Feb 17, 2015
1 parent 482fc8f commit c391ea1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/inflex/pluralize.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ defmodule Inflex.Pluralize do
{ ~r/^(zombie)s$/i, "\\1" },
{ ~r/geese/i, "goose" },
{ ~r/criteria/i, "criterion" },
{ ~r/radii/i, "radius" }
{ ~r/radii/i, "radius" },
{ ~r/^men/i, "man"}
]

@plural_irregular [
{ ~r/person/i, "people" },
{ ~r/^zombies$/i, "zombie" },
{ ~r/goose/i, "geese" },
{ ~r/criterion/i, "criteria" },
{ ~r/radius/i, "radii" }
{ ~r/radius/i, "radii" },
{ ~r/man/i, "men"},
{ ~r/^men/i, "men"},
{ ~r/^women/i, "women"}

]

@singular @irregular ++ [
Expand Down Expand Up @@ -60,7 +65,7 @@ defmodule Inflex.Pluralize do

@plural @plural_irregular ++ [
{ ~r/(child)$/i, "\\1ren" },
{ ~r/(wo|sea)?man$/i, "\\1men" },
{ ~r/(wo)?man$/i, "\\1men" },
{ ~r/(m|l)ouse/i, "\\1ice" },
{ ~r/(database)s$/i, "\\1" },
{ ~r/(quiz)$/i, "\\1zes" },
Expand Down
7 changes: 7 additions & 0 deletions test/inflex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ defmodule InflexTest do
assert "class" == singularize("classes")
assert "woman" == singularize("women")
assert "seaman" == singularize("seamen")
assert "man" == singularize("men")
assert "abdomen" == singularize("abdomens")
assert "specimen" == singularize("specimens")
end

test :pluralize do
Expand All @@ -38,6 +41,10 @@ defmodule InflexTest do
assert "classes" == pluralize("class")
assert "women" == pluralize("woman")
assert "seamen" == pluralize("seaman")
assert "men" == pluralize("men")
assert "women" == pluralize("women")
assert "abdomens" == pluralize("abdomen")
assert "specimens" == pluralize("specimen")
end

test :skip_singularize do
Expand Down

0 comments on commit c391ea1

Please sign in to comment.