Singular and Plural Words using .NET PluralizationServices

Here’s an example of how to use the .NET PluralizationServices library. I usually work with numbers but sometimes I have to work on natural language processing (NLP) projects. A basic NLP task is converting a plural form of a word (such as “processes” or “mice”) to the singular form (“process”, “mouse”), or vice versa.


It’s a surprisingly difficult task if you try to code from scratch. But the .NET Framework 4.5 introduced a PluralizationServices library that’s very handy. The demo code:

using System;
// add reference to System.Data.Entity.Design
using System.Data.Entity.Design.PluralizationServices; 
// visible by default
using System.Globalization;

namespace SingularAndPlural
  class Program
    static void Main(string[] args)
      Console.WriteLine("\nBegin singular and plural words demo");
      Console.WriteLine("Example of .NET PluralizationServices\n");
      CultureInfo ci = new CultureInfo("en-us");
      PluralizationService ps =

      string word = "die";

      if (ps.IsSingular(word) == true)
        Console.WriteLine("The word " + word + " is singluar");
        string plural = ps.Pluralize(word);
        Console.WriteLine("The plural form is " + plural);

      Console.WriteLine("\nModifying the service");
      ((ICustomPluralizationMapping)ps).AddWord("die", "dice");
      string pluralAlt = ps.Pluralize(word);
      Console.WriteLine("\nNow the plural form is " + pluralAlt);

      Console.WriteLine("\nEnd demo\n");
    } // Main
  } // Program
} // ns

The code should be pretty self-explanatory. The demo converts the singular word “die” to its two plural forms, the default “dies” and an alternative “dice” using methods IsSingular and Pluralize. The service also has methods IsPlural and Singularize.

This entry was posted in Machine Learning. Bookmark the permalink.