Ruby Linguistics

Published 11 October 06 by Justin French, 3 comments

Gruber just pointed me in the direction of a very nice Ruby module called Linguistics by Michael Granger and Martin Chase.

Of course it does the usual stuff like plurals, but it’s the Quantifications and Conjunctions that really grabbed my attention.

This:

animals = %w{dog cow ox chicken goose goat cow dog rooster llama pig goat dog cat cat dog cow goat goose goose ox alpaca}
puts "The farm has: " + animals.en.conjunction

Outputs:

The farm has: four dogs, three cows, three geese, three goats, two oxen, two cats, a chicken, a rooster, a llama, a pig, and an alpaca

Thoroughly impressed.

Options

What is this?

portrait of Justin

This is the online home of Justin French, a designer & web application developer located in Melbourne, Australia. I like finding ways to make things work better. I like clarifying and simplifying. I like to understand how you understand things.

» read more

Subscribe to my feed

Follow me on Twitter

@justinfrench

More Notebook Articles

Show more notebook articles

Search