A container for custom acronym casing and exceptions to simple pluralization/singularization rules. Vocabularies.Default contains an extensive list of rules for US English and supports process-wide acronym registration. At this time, multiple vocabularies and removing existing rules are not supported.
public class VocabularyInheritance System.Object → Vocabulary
Adds an acronym whose casing should be preserved when humanizing strings.
public void AddAcronym(string acronym);acronym System.String
The letters in the acronym's canonical output casing, e.g. "HTML".
System.ArgumentNullException
acronym is null.
System.ArgumentException
acronym is empty or contains a non-letter.
Adds a word to the vocabulary which cannot easily be pluralized/singularized by RegEx, e.g. "person" and "people".
public void AddIrregular(string singular, string plural, bool matchEnding=true);singular System.String
The singular form of the irregular word, e.g. "person".
plural System.String
The plural form of the irregular word, e.g. "people".
matchEnding System.Boolean
True to match these words on their own as well as at the end of longer words. False, otherwise.
Adds a rule to the vocabulary that does not follow trivial rules for pluralization, e.g. "bus" -> "buses"
public void AddPlural(string rule, string replacement);rule System.String
RegEx to be matched, case insensitive, e.g. "(bus)es$"
replacement System.String
RegEx replacement e.g. "$1"
Adds a rule to the vocabulary that does not follow trivial rules for singularization, e.g. "vertices/indices -> "vertex/index"
public void AddSingular(string rule, string replacement);rule System.String
RegEx to be matched, case insensitive, e.g. ""(vert|ind)ices$""
replacement System.String
RegEx replacement e.g. "$1ex"
Adds an uncountable word to the vocabulary, e.g. "fish". Will be ignored when plurality is changed.
public void AddUncountable(string word);word System.String
Word to be added to the list of uncountables.
Pluralizes the provided input considering irregular words
public string? Pluralize(string? word, bool inputIsKnownToBeSingular=true);word System.String
Word to be pluralized
inputIsKnownToBeSingular System.Boolean
Normally you call Pluralize on singular words; but if you're unsure call it with false
Singularizes the provided input considering irregular words
public string? Singularize(string? word, bool inputIsKnownToBePlural=true, bool skipSimpleWords=false);word System.String
Word to be singularized
inputIsKnownToBePlural System.Boolean
Normally you call Singularize on plural words; but if you're unsure call it with false
skipSimpleWords System.Boolean
Skip singularizing single words that have an 's' on the end