Skip to main content
Version: 2.14.1

Humanizer.Inflections.Vocabulary

Vocabulary Class

A container for exceptions to simple pluralization/singularization rules. Vocabularies.Default contains an extensive list of rules for US English. At this time, multiple vocabularies and removing existing rules are not supported.

public class Vocabulary

Inheritance System.Object → Vocabulary

Methods

Vocabulary.AddIrregular(string, string, bool) Method

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);

Parameters

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.

Vocabulary.AddPlural(string, string) Method

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);

Parameters

rule System.String

RegEx to be matched, case insensitive, e.g. "(bus)es$"

replacement System.String

RegEx replacement e.g. "$1"

Vocabulary.AddSingular(string, string) Method

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);

Parameters

rule System.String

RegEx to be matched, case insensitive, e.g. ""(vert|ind)ices$""

replacement System.String

RegEx replacement e.g. "$1ex"

Vocabulary.AddUncountable(string) Method

Adds an uncountable word to the vocabulary, e.g. "fish". Will be ignored when plurality is changed.

public void AddUncountable(string word);

Parameters

word System.String

Word to be added to the list of uncountables.

Vocabulary.Pluralize(string, bool) Method

Pluralizes the provided input considering irregular words

public string Pluralize(string word, bool inputIsKnownToBeSingular=true);

Parameters

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

Returns

System.String

Vocabulary.Singularize(string, bool, bool) Method

Singularizes the provided input considering irregular words

public string Singularize(string word, bool inputIsKnownToBePlural=true, bool skipSimpleWords=false);

Parameters

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

Returns

System.String