#594 √ invalid
hqnguyen83

activesupport: "police".singularize returns "polouse"

Reported by hqnguyen83 | July 10th, 2008 @ 05:18 PM | in 2.x

Linux, Ruby 1.8.5, activesupport 2.1.0

activesupport: "police".singularize returns "polouse"

The bug is at line 33 in inflections.rb for active support:

inflect.singular(/([m|l])ice$/i, '\1ouse')

should actually be

inflect.singular(/^([m|l])ice$/i, '\1ouse')

otherwise the pattern matches "police" and converts it to "polouse".

I hope this is the right place to post this.

Comments and changes to this ticket

  • rick

    rick July 10th, 2008 @ 05:28 PM

    • → State changed from “new” to “invalid”

    Why are you calling singularize on a singular word? The inflector doesn't even attempt to guess what form a given word is. If you can come up with a brilliant fix for this that doesn't bloat the code or slow things down tremendously, be my guest :)

  • hqnguyen83

    hqnguyen83 July 10th, 2008 @ 05:43 PM

    It's not a singular word.

    "Hundreds of police deployed to curb J'lem anti-gay pride parade riots"

    This is the first result in google for "hundreds of police" (you can find more, I'm sure). "police" is often used as a plural word, especially in news articles.

    I'm also not quite sure how the suggested change would bloat the code. inflections.rb is a file that contains special cases for the inflector, and all I'm saying is that the regular expression that was supposed to catch "lice" and turn it into "louse" overmatches and catches "police" and turns it into "polouse". The change is a single character.

  • Clemens Kofler

    Clemens Kofler July 10th, 2008 @ 06:05 PM

    Mere curiosity: Why would you put something in an inflector method that shouldn't be pluralized/singularized anyway?

    However, you can fix this by just making it uncountable like e.g. water.

  • hqnguyen83

    hqnguyen83 July 10th, 2008 @ 07:59 PM

    I'm trying to extract entities from text, and when I run across a phrase like "hundreds of *noun*", I assume noun is in plural form, and "hundreds of police", without any trailing noun such as officer or man, is actually quite common, and in these cases, police really is plural.

    But enough of that I guess, since there seems to be disagreement over whether or not police is plural, singular, or neither. Consider the word blouse...activesupport will return "blice" for "blouse".pluralize. My point is, the lice/louse, mice/mouse pairing is the exception, rather than the rule, but that isn't how it is implemented. Right now it overmatches and applies these changes to any string that ends with "louse" or "lice".

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Source available from github

The Git repository resides at http://github.com/rails

Check out the current development trunk (Edge Rails) with:

git clone git://github.com/rails/rails.git

Creating or reviewing a patch

See the contributor guide.

Creating a feature request

Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.

Creating a bug report

When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.

Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.

Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too".

Shared Ticket Bins

People watching this ticket