• (cs)

    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?

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

  • 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?

  • Anon (unregistered) in reply to Mason Wheeler

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

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

  • (cs)

    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.

  • pl (unregistered) in reply to Anon

    Don't forget:

    box => boxen caboose => cabeese

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

  • Rcxdude (unregistered) in reply to Mason Wheeler

    yup, Nethack has a similar makeplural() it's pretty similar, but more comprehensive. Interestingly it also has makesingular()

    spambot thinks this is spam...

  • (cs)

    Not to mention "octopes" and "knifes"!

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

  • (cs)

    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.

  • Bubba (unregistered)

    Why not use Esperanto for our user interfaces?

    No exceptions ever!

  • David (unregistered) in reply to Bubba

    Esperanto doesn't have try/catch?

  • the beholder (unregistered) in reply to Bubba
    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.

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

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

  • (cs)

    So...

    dwarfs, dwarves, or dwerrows?

  • 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 ?

  • Anon (unregistered) in reply to Anonymous Coward
    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.

  • Matt G (unregistered)

    They should've used this: Pluralization Helper for C#

    Captcha: appellatio. Noun. Fellatio in the Appellations.

  • Anon (unregistered) in reply to PB
    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.

  • 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)

  • eros (unregistered) in reply to Anon
    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.
  • Bort (unregistered)

    It's nice to see that Chris Osgood is still saving the day after all these years.

  • (cs) in reply to eros
    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.

  • Tasty (unregistered) in reply to Anon
    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...

  • Greg (unregistered) in reply to Shinobu
    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.
  • ExceptionHandler (unregistered)

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

    CAPTCHA: saluto - salute to brian reagan

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

  • Jay (unregistered) in reply to Bubba
    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!

  • (cs)

    "...it was is PLURALIZED!"

    Muphry's Law strikes again.

  • Jay (unregistered) in reply to Shinobu
    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.

  • wonk (unregistered) in reply to Maurits
    Maurits:
    So...

    dwarfs, dwarves, or dwerrows?

    Midgets.

  • John (unregistered) in reply to Zylon
    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.

  • (cs)

    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.

  • (cs)

    The plural of university is diversity.

  • Anon (unregistered) in reply to Matt G
    Matt G:
    They should've used this: Pluralization Helper for C#

    Captcha: appellatio. Noun. Fellatio in the Appellations.

    Fail: Human -> Humen?

  • Anon (unregistered) in reply to da Doctah
    da Doctah:
    The plural of university is diversity.

    di = two

    So it should be multivesity.

  • Tud (unregistered) in reply to Jay
    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.

  • (cs)

    anyway someone in my team say ICU4J work very well. used by google also.

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

  • Herp Derpington (unregistered) in reply to Anketam

    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.

  • Tractor (unregistered) in reply to the beholder
    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.

  • (cs)

    Shouldn't there be web services for this?

  • (cs) in reply to the beholder
    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?

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

  • Chris Osgreat (unregistered) in reply to Bort
    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?
  • 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!

  • eros (unregistered) in reply to Nagesh
    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.

  • (cs) in reply to Matt G
    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...

Leave a comment on “Pluralized!”

Log In or post as a guest

Replying to comment #372438:

« Return to Article