4 ms·
May I suggest you instead model your inflector's algorithm after Lingua::EN::Inflect? ( http://search.cpan.org/perldoc?Lingua::EN::Inflect http://search.cpan.or
by daxelrod 16y ago
May I suggest you instead model your inflector's algorithm after Lingua::EN::Inflect? ( http://search.cpan.org/perldoc?Lingua::EN::Inflect http://search.cpan.org/perldoc?Lingua::EN::Inflect ) It handles tons of cases better than Rails's inflector does.
Damian Conway (Lingua::EN::Inflect's author) also wrote a paper about algorithmic English pluralization that actually takes a linguistic approach to all of this: http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.ht...
The hard part about an inflector as part of something like a framework is that it's hard to add special cases later when you need corrections, because you risk breaking the existing incorrectly pluralized or singularized names people have for things. It's much easier to get it as right as possible as soon as possible.
- sgrove 16y agoThat's an insane library - I'll definitely take a look at it. This was just meant to be a reasonable stop-gap as I start to build real tools, but you raise some good points. I've book marked the Lingua::EM::Inflect to revisit for porting later - thanks!
- daxelrod 16y agoTo be fair, I've never looked at the source until now and... wow. I'm definitely glad he wrote the paper to go along with it. It's not even that most of the code is hard to read (although a few parts did leave me scratching my head), it's just that without the lingustic explanations I'd be lost. I wouldn't blame you if you held off porting it for the time being. A stopgap measure is definitely better than nothing. I just wanted to make sure you knew about it.