- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Frist! Now I'm somebody on thedailywtf!
Addendum (2012-01-19 12:25): On topic: another case of someone solving the problem within the original problem. Problemception?
Admin
For some reason, this makes me think of NetHack. Its pluralization was pretty impressive. I never took the time to look into the source and see how it was done, though. I wonder if it's a big mess of special cases like this...
Admin
Reminds me of that random sentence generator that I wrote once.
Captcha: illum. Wasn't that one of the planets from Mass Effect?
Admin
It's English. English is nothing but special cases. Every pattern has at least one exception (mouse -> mice, louse -> lice, but house -/-> hice). And then there's the pluralizations using foreign patterns (cactus -> cacti, etc.)
Admin
They chose "Monkey" => "Monkeys" as an example in the comment! Very Freudian.
Presumably no one ever told this ch[iu]mp about l10n.
Admin
If they just used VB, they could put "Option Compare Text" at the top and use the "=" and "Like" operators instead of all that ugly .Equals, .EndsWith, and StringComparison.OrdinalIgnoreCase/InvariantIgnoreCase cruft.
Admin
Don't forget:
box => boxen caboose => cabeese
Admin
On the other hand, I cringe every time an application serves me a ‘You have selected 1 item(s).’ Or even worse: ‘1 items’ It's 2012 and we still get crap like that? Really, the operation system should provide a standard service to put things in the right number, and (for some languages) gender/case.
Admin
yup, Nethack has a similar makeplural() it's pretty similar, but more comprehensive. Interestingly it also has makesingular()
spambot thinks this is spam...
Admin
Not to mention "octopes" and "knifes"!
Admin
I am curious about the domain where "sheep", "leaf", "thief" and "potato" come up as special cases to be individually coded? Either a police booking system for rural sheriff departments, or "The Bard's Tale".
Admin
I tried to write a Pluralize function a couple of years ago. I ended up deciding that in my case it was effectively impossible and the only real answer was to have both strings in the code and select which one to use.
Admin
Why not use Esperanto for our user interfaces?
No exceptions ever!
Admin
Esperanto doesn't have try/catch?
Admin
Admin
for future reference if you need to do this look for a "stemming" class. Usually you specify a language and a word, and it will "stem" it for you.
This is one of those cases, where if you don't know the terminology for what your looking for, you probably won't find it. I had a coworker who wrote his own phone number mask function, and then another mask function for an SSN. He would have kept writing them had I not seen it and told him to look at our mask class.
Admin
A nice example can be found on the Dive into Python tutorial.
Read it here
Askimet also thinks this is spam for some reason ...
Admin
So...
dwarfs, dwarves, or dwerrows?
Admin
I must be WTF, because i don't see anything wrong in this code.
Is it not enough exception-words, what makes it WTF-y ?
Admin
I think one of Askimet's brilliant heuristics for determining if something is spam is:
Notice 37244 suffers the same problem.
Admin
They should've used this: Pluralization Helper for C#
Captcha: appellatio. Noun. Fellatio in the Appellations.
Admin
It's a WTF because it's only called once to turn "item" into "items" and it doesn't even handle the conversion of "is" into "are".
It's both incomplete as a general function and vastly over-engineered for this one, simple case.
Admin
Sorry for taking so long to comment. Yesterday's theDailyWTF motivated me to voluntarily give up DNS use. I had a typo and accidentally went to http://74.50.110.112/ instead of http://74.50.110.120/
I thought it was a new WTF post.
(It took me a while to find an IP with a similar number that would resolve to something that looked like a joke)
Admin
Admin
It's nice to see that Chris Osgood is still saving the day after all these years.
Admin
matter of fact, speaking is easy than writing.
Admin
This reminds me of COBOL's 300 reserved words. They have both is and are so that English speakers can pretend to follow grammar. Yet, these is and are become the same token sent to the parser.
RECORDS IS... RECORD ARE...
Admin
Admin
http://www.youtube.com/watch?v=bTvhhXqpf0A
CAPTCHA: saluto - salute to brian reagan
Admin
To give the author of the function the benefit of the doubt ... perhaps this function was copied from another application that used it more widely, and in that app the author took the approach of writing a general rule, and then adding exceptions as they came up.
If all the text was created by the developers, then you'd know all the special cases and that approach would be acceptable.
That said, a big problem with this theory is that the exceptions given -- tomato, theif, leaf, etc -- are unlikely words to show up in system-generated text. They're more likely general words that might be entered by users. In which case the author is probably an idiot, coding for the handful of special cases that apparently came to his mind on the spur of the moment.
Admin
That would be a great idea if our users spoke Esperanto.
Unfortunately, system developers have to deal with the requirements as they actually exist. We cannot change the requirements to what would be easier to code.
Hey, here's an even simpler idea: Only allow integers to have the value "1". Like, only allow customers to order one of each item, only allow each company to have one employee, etc. Then we'd never need to worry about plurals!
Admin
"...it was is PLURALIZED!"
Muphry's Law strikes again.
Admin
Sure. And the "operation system" should analyze all text and automatically correct it for spelling and grammar errors -- like correcting "operation system" to "operating system" and "serves me" to "displays", etc. And it should write all my programs for me, so I can just say, "Computer, create a web site where customers can order any of the products we sell", and it does it for me. Like the computers work on Star Trek.
Admin
Midgets.
Admin
I can't believe I didn't notice that. I wonder if it was is supposed to be that way?
CAPTCHA: iusto - iusto correctly pluralize words.
Admin
This reminds me of a game I once played, when you are creating your alien species it prompts you to give a name for your species, and in a box next to it, it asks what the plural form is for it.
Admin
The plural of university is diversity.
Admin
Fail: Human -> Humen?
Admin
di = two
So it should be multivesity.
Admin
The operating system should do whatever is useful and needed by many applications. Stuff such as pluralizing and basic language manipulation is needed in lots and lots of applications, thus making you a moron. And if the OS could actually do what you said it would be good.
Still, I bet there already ARE libraries for this stuff, and possibly already included in many systems as well.
Admin
anyway someone in my team say ICU4J work very well. used by google also.
http://site.icu-project.org/
Admin
Yes, I used to play a few games that did this, I enjoyed things such as: Race: Herp Derp Plural: Sheeple
or
Race: Vulcan Plural: Penis
because I'm a child an easily amused.
Admin
I imagine it wouldn't make much of a difference. Users don't read what's on the screen anyway.
Admin
Shouldn't there be web services for this?
Admin
Admin
I've used http://code.google.com/p/inflection-js/ before. Its pluralize function is pretty friggin awesome. On closer inspection, I found it used these new-fangled thingies called regular expressions. If I saw good regular expressions more regularly I'd make some happy expressions.
Admin
Admin
English pluralization is brutally difficult. The Perl module Lingua::EN::Inflect does an amazingly good job.
Besides handling pluralization, it also handles verb inflection (is/are, was/were), article selection (a/an), ordinal inflection (1st, 2nd, 3rd, 100th), and much more. It's an amazing piece of code.
It's a lot longer than the (bad) WTF example, but surprisingly it manages to do all this in just over 1,600 lines of code!
Admin
Admin