Skip to content

Commit

Permalink
fix inflector bug where -ice gets pluralized into -ouse
Browse files Browse the repository at this point in the history
This should happen for mouse or louse, but not slice or pumice.
  • Loading branch information
cap10morgan committed Feb 25, 2012
1 parent cbe74cf commit 16e7f2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions activesupport/lib/active_support/inflections.rb
Expand Up @@ -16,8 +16,8 @@ module ActiveSupport
inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies')
inflect.plural(/(x|ch|ss|sh)$/i, '\1es')
inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices')
inflect.plural(/(m|l)ouse$/i, '\1ice')
inflect.plural(/(m|l)ice$/i, '\1ice')
inflect.plural(/^(m|l)ouse$/i, '\1ice')
inflect.plural(/^(m|l)ice$/i, '\1ice')
inflect.plural(/^(ox)$/i, '\1en')
inflect.plural(/^(oxen)$/i, '\1')
inflect.plural(/(quiz)$/i, '\1zes')
Expand All @@ -36,7 +36,7 @@ module ActiveSupport
inflect.singular(/(s)eries$/i, '\1eries')
inflect.singular(/(m)ovies$/i, '\1ovie')
inflect.singular(/(x|ch|ss|sh)es$/i, '\1')
inflect.singular(/(m|l)ice$/i, '\1ouse')
inflect.singular(/^(m|l)ice$/i, '\1ouse')
inflect.singular(/(bus)(es)?$/i, '\1')
inflect.singular(/(o)es$/i, '\1')
inflect.singular(/(shoe)s$/i, '\1')
Expand All @@ -58,6 +58,6 @@ module ActiveSupport
inflect.irregular('cow', 'kine')
inflect.irregular('zombie', 'zombies')

inflect.uncountable(%w(equipment information rice money species series fish sheep jeans))
inflect.uncountable(%w(equipment information rice money species series fish sheep jeans police))
end
end
4 changes: 3 additions & 1 deletion activesupport/test/inflector_test_cases.rb
Expand Up @@ -109,7 +109,9 @@ module InflectorTestCases

# regression tests against improper inflection regexes
"|ice" => "|ices",
"|ouse" => "|ouses"
"|ouse" => "|ouses",
"slice" => "slices",
"police" => "police"
}

CamelToUnderscore = {
Expand Down

1 comment on commit 16e7f2f

@jasonnoble
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ egrep '(m|l)ouse$' /usr/share/dict/words
blouse
coalmouse
colemouse
creepmouse
delouse
dormouse
flittermouse
flouse
jalouse
louse
mouse
overblouse
pricklouse
rattlemouse
reremouse
shearmouse
shrewmouse
smouse
talmouse
titmouse
tittymouse
Tomtitmouse
zamouse
$ egrep '^(m|l)ouse$' /usr/share/dict/words
louse
mouse
$ egrep '(m|l)ice$' /usr/share/dict/words
accomplice
Alice
allice
amice
chalice
cilice
complice
Ellice
enchalice
fortalice
malice
mice
police
prepolice
pumice
pummice
resplice
slice
splice
supplice
surplice
Triplice
undersplice
unsurplice
$ egrep '^(m|l)ice$' /usr/share/dict/words
mice
$

It does appear that without this change, quite a few words would be wrong. Blouse => Blice for example.

Please sign in to comment.