# Pluralize Bug?

**URL:** <https://www.ruby-forum.com/t/pluralize-bug/69658>\
**Category:** Rails\
**Created:** [September 22, 2006, 6:43pm UTC](https://www.ruby-forum.com/t/pluralize-bug/69658 "2006-09-22T18:43:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e19adc/32.png) [@Clare](https://www.ruby-forum.com/u/Clare)\
**Post date:** [September 22, 2006, 6:43pm UTC](https://www.ruby-forum.com/t/pluralize-bug/69658/1 "2006-09-22T18:43:26Z")

</div>

I am using Pluralize and it is working well… but…

pluralizing on “glass” comes back with “glas” and “glasses” and does not  
return “glass”.

I am using Ferret to then search using the pluralized terms but I then  
get no results because I do not find the items with “glass” in the  
title.

This works on every other term that I can think of… just not the term  
“Glass”…

Any ideas?

---

<div class="post-metadata">

**Author:** ![Clare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e19adc/32.png) [@Clare](https://www.ruby-forum.com/u/Clare)\
**Post date:** [September 22, 2006, 7:01pm UTC](https://www.ruby-forum.com/t/pluralize-bug/69658/2 "2006-09-22T19:01:57Z")

</div>

On 9/23/06, Clare [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This works on every other term that I can think of… just not the term  
> “Glass”…
> 
> Any ideas?

Hi Clare,

If you are doing this so that you can search for both pluralized and  
non-pluralized versions of a term then you’d be better off using  
Ferret’s StemFilter. Otherwise, I’ll leave the answer to this up to  
the rails people.

Cheers,  
Dave

---

<div class="post-metadata">

**Author:** ![Clare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e19adc/32.png) [@Clare](https://www.ruby-forum.com/u/Clare)\
**Post date:** [September 22, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/pluralize-bug/69658/3 "2006-09-22T19:07:58Z")

</div>

Why not set your query to return results on the singular OR the plural  
form? Also you can add new inflection rules in the environment.rb  
file. Don’t forget to restart the server if you make edits to that  
file.

---

<div class="post-metadata">

**Author:** ![Clare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e19adc/32.png) [@Clare](https://www.ruby-forum.com/u/Clare)\
**Post date:** [September 22, 2006, 7:18pm UTC](https://www.ruby-forum.com/t/pluralize-bug/69658/4 "2006-09-22T19:18:47Z")

</div>

Thank you all for the answers, I added the following line to  
enviroment.rb and uncoomented the rest (I played with variations of  
commenting/uncommenting) and restarted the server a few times but it  
produces glasses OR glas. Id there anything else that i have to do apart  
from uncommenting the inflector bit + is there a better way to catch  
more than just glass? Would anyone like to share their upgraded  
inflector rules for english language?

Inflector.inflections do |inflect|  
inflect.irregular ‘glass’, ‘glasses’  
inflect.plural /^(ox)$/i, ‘\1en’  
inflect.singular /^(ox)en/i, ‘\1’  
inflect.irregular ‘person’, ‘people’  
inflect.uncountable %w( fish sheep )  
end

Dave: Will look into StemFilter, thanks for that.

Thanks  
regards  
c

---

<div class="post-metadata">

**Author:** ![Clare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e19adc/32.png) [@Clare](https://www.ruby-forum.com/u/Clare)\
**Post date:** [September 22, 2006, 7:25pm UTC](https://www.ruby-forum.com/t/pluralize-bug/69658/5 "2006-09-22T19:25:59Z")

</div>

On 9/23/06, Brian G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Why not set your query to return results on the singular OR the plural  
> form? Also you can add new inflection rules in the environment.rb  
> file. Don’t forget to restart the server if you make edits to that  
> file.

Hi Brian,

That’s what using the StemFilter in Ferret will do. Plus it will  
search for other forms of the word. For example, “burn” will also  
match “burns”, “burned” and “burning”.

Cheers,  
Dave

---

<div class="post-metadata">

**Author:** ![Clare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e19adc/32.png) [@Clare](https://www.ruby-forum.com/u/Clare)\
**Post date:** [September 22, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/pluralize-bug/69658/6 "2006-09-22T19:28:02Z")

</div>

glass is considered uncountable unless you mean eye glasses or drinking  
glasses

you don’t need to uncomment the rest because they are already loaded by  
default. they are there as examples.

StemFilter may be overkill unless Clare wants to search for all forms of  
a  
word.

---

<div class="post-metadata">

**Author:** ![Clare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e19adc/32.png) [@Clare](https://www.ruby-forum.com/u/Clare)\
**Post date:** [September 24, 2006, 2:22am UTC](https://www.ruby-forum.com/t/pluralize-bug/69658/7 "2006-09-24T02:22:28Z")

</div>

Robert H. \<rails-mailing-list@…\> writes:

> Clare wrote:
> 
> > inflect.plural /^(ox)$/i, ‘\1en’  
> > inflect.singular /^(ox)en/i, ‘\1’
> 
> I don’t recommend these. You’ll get box / boxen, which is mildly  
> amusing to dorks like us, but probably not what you intended.

Well, it would if there wasn’t a ^ at the start of that regular  
expression. In  
any case you don’t get a choice because it’s one of the default rules  
which is  
already loaded, as mentioned above

---

<div class="post-metadata">

**Author:** ![Clare](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e19adc/32.png) [@Clare](https://www.ruby-forum.com/u/Clare)\
**Post date:** [September 22, 2006, 7:59pm UTC](https://www.ruby-forum.com/t/pluralize-bug/69658/8 "2006-09-22T19:59:05Z")

</div>

Clare wrote:

> inflect.plural /^(ox)$/i, ‘\1en’  
> inflect.singular /^(ox)en/i, ‘\1’

I don’t recommend these. You’ll get box / boxen, which is mildly  
amusing to dorks like us, but probably not what you intended.
