Friday, June 22, 2007

Truly Plural!

I was working on a small shell script to generate stubs for a project we're working on. After arriving at a rough design and deciding on the class names, method names to be generated, I started generating the stubs (scaffolding?). And came across an amusing non technical issue. getBench() was fine, but getBenchs() wasn't. It should've been getBenches().

Uh, oh! There might be a tool that can generate plurals given a word ?

Doing a quick search threw up a perl library to achieve the same. Three cheers for Perl !!! I'm always amazed at the huge number of modules Perl has. Anyway's here's a simple wrapper I wrote for that library which you can use to get plurals for most nouns.

shashi@anacoluthon:~$ pluralize.pl bench
benches

While at it, I happened to notice there's an implementation for Python and also a Grammar ruleset for implementing elsewhere.

PS: Title Inspiration: "A truly rural frugal ruler's mural" - tongue twister

1 comment:

ravi said...

Oh! This title is a play on the tonguetwister — “Truly Ruler”!

truly ruler ...
truly ruler ...
truly ruler ...
truly rural ...
truly rulal ...
truly lulal ...
twooly looal ...
wooli lulaal ... !