Package io.inversion.utils
Class Pluralizer
java.lang.Object
io.inversion.utils.Pluralizer
Transforms English words from singular to plural form.
Examples:
English.plural("word") = "words";
English.plural("cat", 1) = "cat";
English.plural("cat", 2) = "cats";
Based on An Algorithmic Approach to English Pluralization by Damian Conway.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcategoryRule(String[] list, String singular, String plural) protected StringReturns singular or plural form of the word based on count.protected voidprotected voidstatic StringReturns plural form of the given word.static StringReturns singular or plural form of the word based on count.protected voidprotected voidstatic voidsetMode(io.inversion.utils.Pluralizer.MODE mode) protected voiduncountable(String[] list)
-
Constructor Details
-
Pluralizer
public Pluralizer() -
Pluralizer
public Pluralizer(io.inversion.utils.Pluralizer.MODE mode)
-
-
Method Details
-
plural
Returns plural form of the given word. For instance:English.plural("cat") == "cats";- Parameters:
word- word in singular form- Returns:
- plural form of given word
-
plural
Returns singular or plural form of the word based on count. For instance:English.plural("cat", 1) == "cat"; English.plural("cat", 2) == "cats";- Parameters:
word- word in singular formcount- word count- Returns:
- form of the word correct for given count
-
setMode
public static void setMode(io.inversion.utils.Pluralizer.MODE mode) -
getPlural
Returns singular or plural form of the word based on count.- Parameters:
word- word in singular formcount- word count- Returns:
- form of the word correct for given count
-
getPlural
-
uncountable
-
irregular
-
irregular
-
rule
-
rule
-
categoryRule
-