Comment On Pluralized!

"When digging through some code that was on the refactor list, I came accross some validation logic that checks if the user selected enough options on the form," writes Chris Osgood, "if enough options weren't selected, you'd get an error message along that said something like 'at least 3 options are required'." [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: Pluralized!

2012-01-19 12:17 • by lettucemode
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?

Re: Pluralized!

2012-01-19 12:18 • by Mason Wheeler (unregistered)
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...

Re: Pluralized!

2012-01-19 12:25 • by Andrew (unregistered)
Reminds me of that random sentence generator that I wrote once.

Captcha: illum. Wasn't that one of the planets from Mass Effect?

Re: Pluralized!

2012-01-19 12:25 • by Anon (unregistered)
372437 in reply to 372434
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.)

Re: Pluralized!

2012-01-19 12:30 • by pl (unregistered)
They chose "Monkey" => "Monkeys" as an example in the comment! Very Freudian.

Presumably no one ever told this ch[iu]mp about l10n.

Re: Pluralized!

2012-01-19 12:32 • by dtfinch
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.

Re: Pluralized!

2012-01-19 12:36 • by pl (unregistered)
372440 in reply to 372437
Don't forget:

box => boxen
caboose => cabeese

Re: Pluralized!

2012-01-19 12:43 • by Shinobu (unregistered)
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.

Re: Pluralized!

2012-01-19 12:44 • by Rcxdude (unregistered)
372444 in reply to 372434
yup, Nethack has a similar makeplural() it's pretty similar, but more comprehensive. Interestingly it also has makesingular()

spambot thinks this is spam...

Re: Pluralized!

2012-01-19 12:44 • by ekolis
Not to mention "octopes" and "knifes"!

Re: Pluralized!

2012-01-19 12:49 • by Mr Keith (unregistered)
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".

Re: Pluralized!

2012-01-19 12:52 • by Loren Pechtel
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.

Re: Pluralized!

2012-01-19 13:14 • by Bubba (unregistered)
Why not use Esperanto for our user interfaces?

No exceptions ever!

Re: Pluralized!

2012-01-19 13:18 • by David (unregistered)
372451 in reply to 372450
Esperanto doesn't have try/catch?

Re: Pluralized!

2012-01-19 13:20 • by the beholder (unregistered)
372452 in reply to 372450
Bubba:
Why not use Esperanto for our user interfaces?

No exceptions ever!
Because if we already have stupid support calls as it is today, imagine if our users weren't able to read what's on the screen.

Re: Pluralized!

2012-01-19 13:20 • by steve (unregistered)
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.

Re: Pluralized!

2012-01-19 13:21 • by Anonymous Coward (unregistered)
A nice example can be found on the Dive into Python tutorial.

Read it here

Askimet also thinks this is spam for some reason ...

Re: Pluralized!

2012-01-19 13:26 • by Maurits
So...

dwarfs, dwarves, or dwerrows?

Re: Pluralized!

2012-01-19 13:26 • by PB (unregistered)
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 ?

Re: Pluralized!

2012-01-19 13:30 • by Anon (unregistered)
372458 in reply to 372454
Anonymous Coward:
A nice example can be found on the Dive into Python tutorial.

Read it here

Askimet also thinks this is spam for some reason ...


I think one of Askimet's brilliant heuristics for determining if something is spam is:


if (message ends with a url)
IsSpam = true;


Notice 37244 suffers the same problem.

Re: Pluralized!

2012-01-19 13:32 • by Matt G (unregistered)
They should've used this: Pluralization Helper for C#

Captcha: appellatio. Noun. Fellatio in the Appellations.

Re: Pluralized!

2012-01-19 13:33 • by Anon (unregistered)
372460 in reply to 372457
PB:
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 ?


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.

Re: Pluralized!

2012-01-19 13:35 • by Jon E. (unregistered)
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)

Re: Pluralized!

2012-01-19 13:37 • by eros (unregistered)
372463 in reply to 372437
Anon:
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.)

Yeah, spoken language is a bitch, eh? Amazing how people make common things easier/quicker to say.

Re: Pluralized!

2012-01-19 13:53 • by Bort (unregistered)
It's nice to see that Chris Osgood is still saving the day after all these years.

Re: Pluralized!

2012-01-19 13:56 • by Nagesh
372468 in reply to 372463
eros:
Anon:
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.)

Yeah, spoken language is a bitch, eh? Amazing how people make common things easier/quicker to say.


matter of fact, speaking is easy than writing.

Re: Pluralized!

2012-01-19 13:57 • by Tasty (unregistered)
372469 in reply to 372460
Anon:
PB:
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 ?


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.


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...

Re: Pluralized!

2012-01-19 14:01 • by Greg (unregistered)
372470 in reply to 372442
Shinobu:
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.

Yeah, language procesing is realy an core OS funxion. Its a bit wierd tho two here some one who cunt spell operating system bitch aboot "1 items". Its the gremmer nazis trap, I gess.

Re: Pluralized!

2012-01-19 14:01 • by ExceptionHandler (unregistered)

http://www.youtube.com/watch?v=bTvhhXqpf0A

CAPTCHA: saluto - salute to brian reagan

Re: Pluralized!

2012-01-19 14:04 • by Jay (unregistered)
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.

Re: Pluralized!

2012-01-19 14:07 • by Jay (unregistered)
372473 in reply to 372450
Bubba:
Why not use Esperanto for our user interfaces?

No exceptions ever!


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!

Re: Pluralized!

2012-01-19 14:08 • by Zylon
"...it was is PLURALIZED!"

Muphry's Law strikes again.

Re: Pluralized!

2012-01-19 14:12 • by Jay (unregistered)
372475 in reply to 372442
Shinobu:
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.


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.

Re: Pluralized!

2012-01-19 14:23 • by wonk (unregistered)
372476 in reply to 372456
Maurits:
So...

dwarfs, dwarves, or dwerrows?


Midgets.

Re: Pluralized!

2012-01-19 14:26 • by John (unregistered)
372477 in reply to 372474
Zylon:
"...it was is PLURALIZED!"

Muphry's Law strikes again.


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.

Re: Pluralized!

2012-01-19 14:49 • by Anketam
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.

Re: Pluralized!

2012-01-19 14:49 • by da Doctah
The plural of university is diversity.

Re: Pluralized!

2012-01-19 14:53 • by Anon (unregistered)
372484 in reply to 372459
Matt G:
They should've used this: Pluralization Helper for C#

Captcha: appellatio. Noun. Fellatio in the Appellations.


Fail: Human -> Humen?

Re: Pluralized!

2012-01-19 14:54 • by Anon (unregistered)
372485 in reply to 372483
da Doctah:
The plural of university is diversity.


di = two

So it should be multivesity.

Re: Pluralized!

2012-01-19 14:56 • by Tud (unregistered)
372486 in reply to 372475
Jay:
Shinobu:
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.


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.



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.

Re: Pluralized!

2012-01-19 15:01 • by Nagesh
anyway someone in my team say ICU4J work very well. used by google also.

http://site.icu-project.org/

Re: Pluralized!

2012-01-19 15:03 • by Herp Derpington (unregistered)
372489 in reply to 372482
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.

Re: Pluralized!

2012-01-19 15:06 • by Tractor (unregistered)
372490 in reply to 372452
the beholder:
Bubba:
Why not use Esperanto for our user interfaces?

No exceptions ever!
Because if we already have stupid support calls as it is today, imagine if our users weren't able to read what's on the screen.


I imagine it wouldn't make much of a difference. Users don't read what's on the screen anyway.

Re: Pluralized!

2012-01-19 15:08 • by frits
Shouldn't there be web services for this?

Re: Pluralized!

2012-01-19 15:09 • by D-Coder
372492 in reply to 372452
the beholder:
Bubba:
Why not use Esperanto for our user interfaces?

No exceptions ever!
Because if we already have stupid support calls as it is today, imagine if our users weren't able to read what's on the screen.
And that would be different... how?

Re: Pluralized!

2012-01-19 15:10 • by Ben Jammin (unregistered)
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.

Re: Pluralized!

2012-01-19 15:11 • by Chris Osgreat (unregistered)
372494 in reply to 372467
Bort:
It's nice to see that Chris Osgood is still saving the day after all these years.

Perhaps Alex's ability to detect pseudonyms is Peter Ing out?

Re: Pluralized!

2012-01-19 15:23 • by Dave Rolsky (unregistered)
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!

Re: Pluralized!

2012-01-19 15:23 • by eros (unregistered)
372497 in reply to 372468
Nagesh:
eros:
Anon:
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.)

Yeah, spoken language is a bitch, eh? Amazing how people make common things easier/quicker to say.


matter of fact, speaking is easy than writing.

Don't reply to my posts, you fake-Indian jerk-off.

Re: Pluralized!

2012-01-19 15:29 • by C-Octothorpe
372498 in reply to 372459
Matt G:
They should've used this: Pluralization Helper for C#

Captcha: appellatio. Noun. Fellatio in the Appellations.
Love the first comment:
Naveen:
HI

I am Naveen.I had learnt ,how to run selenium IDE & selenium RC.The main thing is how to generate a Test Report after the running the test Succesfully.I am using the Selenium RC and NUNIT for the testing .How to get the Test actions and descriptions in a Report.And another thing is How to run Selenium Core and when it is useful .And suggest some more open source tools for testing .Net and Java Projects ………………………..

Try to help me…..

Thanks
Naveen
Nagesh's cousin, I suppose...
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment