Skip to content

Instantly share code, notes, and snippets.

@the21st
Created February 12, 2014 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the21st/8952586 to your computer and use it in GitHub Desktop.
Save the21st/8952586 to your computer and use it in GitHub Desktop.
.NET pluralize decompiled
private string InternalPluralize(string word)
{
if (this._userDictionary.ExistsInFirst(word))
return this._userDictionary.GetSecondValue(word);
if (this.IsNoOpWord(word))
return word;
string prefixWord;
string suffixWord = this.GetSuffixWord(word, out prefixWord);
if (this.IsNoOpWord(suffixWord) || this.IsUninflective(suffixWord) || (this._knownPluralWords.Contains(suffixWord.ToLowerInvariant()) || this.IsPlural(suffixWord)) || this._irregularPluralsPluralizationService.ExistsInFirst(suffixWord))
return prefixWord + suffixWord;
string newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"man"
}, (Func<string, string>) (s => s.Remove(s.Length - 2, 2) + "en"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"louse",
"mouse"
}, (Func<string, string>) (s => s.Remove(s.Length - 4, 4) + "ice"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"tooth"
}, (Func<string, string>) (s => s.Remove(s.Length - 4, 4) + "eeth"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"goose"
}, (Func<string, string>) (s => s.Remove(s.Length - 4, 4) + "eese"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"foot"
}, (Func<string, string>) (s => s.Remove(s.Length - 3, 3) + "eet"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"zoon"
}, (Func<string, string>) (s => s.Remove(s.Length - 3, 3) + "oa"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"cis",
"sis",
"xis"
}, (Func<string, string>) (s => s.Remove(s.Length - 2, 2) + "es"), this.Culture, out newWord) || this._assimilatedClassicalInflectionPluralizationService.ExistsInFirst(suffixWord) || this._classicalInflectionPluralizationService.ExistsInFirst(suffixWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"trix"
}, (Func<string, string>) (s => s.Remove(s.Length - 1, 1) + "ces"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"eau",
"ieu"
}, (Func<string, string>) (s => s + "x"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"inx",
"anx",
"ynx"
}, (Func<string, string>) (s => s.Remove(s.Length - 1, 1) + "ges"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"ch",
"sh",
"ss"
}, (Func<string, string>) (s => s + "es"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"alf",
"elf",
"olf",
"eaf",
"arf"
}, (Func<string, string>) (s =>
{
if (!s.EndsWith("deaf", true, this.Culture))
return s.Remove(s.Length - 1, 1) + "ves";
else
return s;
}), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"nife",
"life",
"wife"
}, (Func<string, string>) (s => s.Remove(s.Length - 2, 2) + "ves"), this.Culture, out newWord))
return prefixWord + newWord;
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"ay",
"ey",
"iy",
"oy",
"uy"
}, (Func<string, string>) (s => s + "s"), this.Culture, out newWord))
return prefixWord + newWord;
if (suffixWord.EndsWith("y", true, this.Culture))
return prefixWord + suffixWord.Remove(suffixWord.Length - 1, 1) + "ies";
if (this._oSuffixPluralizationService.ExistsInFirst(suffixWord))
return prefixWord + this._oSuffixPluralizationService.GetSecondValue(suffixWord);
if (PluralizationServiceUtil.TryInflectOnSuffixInWord(suffixWord, (IEnumerable<string>) new List<string>()
{
"ao",
"eo",
"io",
"oo",
"uo"
}, (Func<string, string>) (s => s + "s"), this.Culture, out newWord))
return prefixWord + newWord;
if (suffixWord.EndsWith("o", true, this.Culture) || !suffixWord.EndsWith("x", true, this.Culture))
return prefixWord + suffixWord + "es";
else
return prefixWord + suffixWord + "es";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment