Making plurals singular?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Making plurals singular?

Post by Mr Tech »

Is it possible to make a plural (e.g: surfers) into a singular work (e.g: surfer)? And if the word is already singular, the script doesn't do anything.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Sure, it's possible. I have no drive to try doing it myself though. :)
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

Any idea what php function would do this? Or is it more complex?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

you could do some sort of regex, but then you'd have to think of all the ways that a word can be plural. Some words end in ies, some in s, some in es, some don't even end in an s at all. That would be a pretty crazy regex. I'm kind of curious how this could be accomplished too.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I think that is more logic than regex. I also think you are tackling an enormous mountain of anguish and pain if you try to do this. Just my $0.02.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

sounds fun! Image
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

I'm sure with a set of unit tests you could get something reasonably accurate.
Post Reply