Is there any function (VB.NET or C#) that can transform an English word into its singular or to its plural form?
I was thinking of having a database that contains all words in English as well as their plural form but I also think that it is stupid since that will be huge and besides there are rules in English on how to translate a word to its plural form, so why not create a function that does the transformation?
You can use Humanizer micro library. It's capable of this and a lot more.
Disclaimer: I am the creator of the library.
In the System.Data.Entity.Design dll there is a namespace called PluralizationServices.
System.Data.Entity.Design.PluralizationServices.PluralizationService.CreateService(CultureInfo.GetCultureInfo("en-us")) will give you an object that exposes the self explanatory Pluralize, Singularize, IsPlural and IsSingular methods.
EF uses it to pluralize and singularize table names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With