C# Plural Singular
Latest Blogs...
My latest music tracks
Google Weather
How fast is your code
Add plural/singular words to your keyword searches
Merry Xmas
Skip Navigation Links.

C# Plural Singular

Skip Navigation LinksHome :: ASP.NET :: C# :: Plural to Singular

Do you need to convert words (nouns) from singular to plural and/or convert words from plural to singular? Here's a C# class to do it for you!
Ideal for database searches to ensure accurate recordsets are returned whether (or not) your visitors enter a plural or singular word to search on.
You can't just add an 's' on the end of a word to create a plural.
How does it work? There are rules by which plurals are constructed. With a bit of string parsing we can deduce the plural of a noun.
Of course there are some words that do not conform (irregular nouns) so we have a dictionary to cope with those. There are only 100 such words so this is far more lightweight than looking up in a 'real' dictionary. I did think of hooking into an Office .dic file but thought better of it!
Being a singleton class means it is cached (well a single instance is on the garbage collected heap) for fast access without further instantiations.
Use in conjuction with Stopwords to create a fantastic search algorithm.
It's not perfect, but it is pretty close! here's the source code (Word .doc)
wordsingularplural
manmanmen
aaa
tototo
boyboyboys
GirlsgirlGirls
ChildrenchildChildren
peoplepersonpeople
babiesbabybabies
churchchurchchurches
buzzesbuzzbuzzes
familyfamilyfamilies
boxesboxboxes
babybabybabies
foxfoxfoxes
bushesbushbushes
micemousemice
The above is a test. Note that two letter words aren't touched (and likewise, if a word is already a plural/singular it is not converted). Next >> Google Weather
top of page
©1996/2010 BennySutton.com
All images © their respective owners
Powered By ADz This site uses Thumbshots previews