Is there any algorithm in c# to singularize - pluralize a word?

You also have the System.Data.Entity.Design.PluralizationServices.PluralizationService.

UPDATE: Old answer deserves update. There's now also Humanizer: https://github.com/MehdiK/Humanizer


I can do it for Esperanto, with no special cases!

string plural(string noun) { return noun + "j"; }

For English, it would be useful to become familiar with the rules for Regular Plurals of Nouns, as well as Irregular Plurals of Nouns. There is a whole Wikipedia article on the English plural, which may have some helpful information too.


Most ORMs have a stab at it, although they generally aren't perfect. I know Castle has it's Inflector Class you can probably poke around. Doing it "perfectly" isn't an easy task though (English "rules" aren't really rules :)), so it depends if you are happy with a "reasonable guess" approach.

Tags:

C#

Algorithm