Inflections for the word "forum"

1 view
Skip to first unread message

dmarkow

unread,
May 9, 2008, 1:23:20 PM5/9/08
to merb
I was having trouble getting the singular of "forum" to stay as is.
Merb always wants to change it to "fora". I tried adding a specific
inflection rule but it still gives me "fora." Running on merb 0.9.3

~ Loaded DEVELOPMENT Environment...
~ loading gem 'merb_datamapper' ...
~ Connecting to database...
~ Compiling routes...
~ Using 'share-nothing' cookie sessions (4kb limit per client)
>> "forum".plural
=> "forums"
>> "forum".singular
=> "fora"
>> Language::English::Inflect.word "forum", "forums"
=> "forums"
>> "forum".plural
=> "forums"
>> "forum".singular
=> "fora"
>>

I wound up just manually removing the "ra/rum" rules by doing this,
but I was curious to see if this was the "Correct" way or not?

Language::English::Inflect.pluralization_rules.reject!{ |x,y| x == /ra
$/ }
Language::English::Inflect.singularization_rules.reject!{ |x,y| x == /
rum$/ }

Max

unread,
May 12, 2008, 3:21:22 PM5/12/08
to merb
Hey dmarkow,

After a bit of hunting around for the correct file to actually edit
(no, not the English gem, no, not my local gem repo), I think the most
"correct" solution is to alter the singular methods and plural methods
by adding the line with the stars... of course, this would get
overwritten in the next update to merb-core, but uh, I'll submit it as
a ticket in the proper place.

def singular(word)
if result = singular_of[word]
return result.dup
end
result = word.dup
**return result if singular_of.value? result**
singularization_rules.each do |(match, replacement)|
break if result.gsub!(match, replacement)
end
return result
end

def plural(word)
if result = plural_of[word]
return result.dup
end
#return self.dup if /s$/ =~ self # ???
result = word.dup
**return result if plural_of.value? result**
pluralization_rules.each do |(match, replacement)|
break if result.gsub!(match, replacement)
end
return result
end

The file is located at /usr/lib/ruby/gems/1.8/gems/merb-core-0.9.3/lib/
merb-core/vendor/facets/inflect.rb on my Ubuntu box.

Michael Klishin

unread,
May 13, 2008, 7:06:44 AM5/13/08
to merb
On May 12, 10:21 pm, Max <nanode...@gmail.com> wrote:
>       def singular(word)
>         if result = singular_of[word]
>           return result.dup
>         end
>         result = word.dup
>         **return result if singular_of.value? result**
>         singularization_rules.each do |(match, replacement)|
>           break if result.gsub!(match, replacement)
>         end
>         return result
>       end

First thing, there is pastie.org and pastie.textmate.org for code
snippets.
Second is, I wrote a spec for "forum".singular case and double-starred
line
in the code above does not make it pass.

I'll be covering inflector with extra specs today so we can experiment
with changes.

MK

Michael Klishin

unread,
May 13, 2008, 8:09:31 AM5/13/08
to merb
On May 12, 10:21 pm, Max <nanode...@gmail.com> wrote:
>         **return result if singular_of.value? result**

Max,

I am sorry, your change actually does fix forum case when exception
for it
it added.

Spec suite exposed at least one bug (vertex => vetices typo). I am
pushing it to my merb tree at github:

git://github.com/michaelklishin/merb-core.git

If you want to contribute, check up existing specs in spec/private/
vendor/inflector_spec.rb (master branch)
and just add your own cases.

MK
Reply all
Reply to author
Forward
0 new messages