fix inflector bug where -ice gets singularized into -ouse #5177

Merged
merged 1 commit into from Apr 30, 2012

Conversation

Projects
None yet
7 participants
Contributor

cap10morgan commented Feb 25, 2012

This should happen for mouse or louse, but not slice or pumice.

I know the inflector is "frozen," but this is a pretty cut and dry bug with a very simple fix. It doesn't seem likely that there are many cases out there where this bug fix will break existing code.

Fixes issue #4374.

@cap10morgan cap10morgan fix inflector bug where -ice gets pluralized into -ouse
This should happen for mouse or louse, but not slice or pumice.
16e7f2f
Contributor

jasonnoble commented Feb 25, 2012

+1

Member

vijaydev commented Feb 26, 2012

mrpta commented Apr 6, 2012

I have found another similar bug where "Pies" becomes "Py".

Contributor

jeremyf commented Apr 28, 2012

@cap10morgan If the inflector is frozen, then it seems like we shouldn't re-open it.

cc @josevalim

Confirmed, inflections in Rails are frozen, it won't accept more changes. If you need to handle that in your application, just add the required rules to your initializer file. Thanks!

Contributor

cap10morgan commented Apr 29, 2012

I understand that the inflector is frozen against future additions. But surely it shouldn't be frozen against bug fixes. This issue should either be fixed or the offending inflections removed entirely. Doing nothing breaks Rails apps that hit this bug.

Member

josevalim commented Apr 29, 2012

@cap10morgan the issue is: can we be sure that this change is not going to break other people's app because there are other words that would match the regexp but not they won't? How many words are we breaking and how many words are we fixing with this patch? If someone can run those regexps over a dictionary so we can get 20-ish sample words to have an idea, it would be awesome. Otherwise, I think we should not merge it.

$ 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.

Contributor

cap10morgan commented Apr 30, 2012

@jasonnoble Thanks for doing that. I posted a similar list to the original issue here: #4374 (comment)

Member

josevalim commented Apr 30, 2012

@jasonnoble nice, cool trick :)

ok, merging this, thanks everyone!

josevalim reopened this Apr 30, 2012

@josevalim josevalim added a commit that referenced this pull request Apr 30, 2012

@josevalim josevalim Merge pull request #5177 from cap10morgan/fix-gh-issue-4374
fix inflector bug where -ice gets singularized into -ouse
66c5ac3

@josevalim josevalim merged commit 66c5ac3 into rails:master Apr 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment