Java Utililty Methods String Singularize

List of utility methods to do String Singularize

Description

The list of methods to do String Singularize are organized into topic(s).

Method

Stringsingular(String plural)
singular
if (plural.equalsIgnoreCase("people")) {
    return plural.charAt(0) + "erson";
} else if (plural.equalsIgnoreCase("alumni")) {
    return plural.charAt(0) + "lumnus";
} else if (plural.endsWith("ies")) {
    return plural.substring(0, plural.length() - 3) + 'y';
} else if ('s' == plural.charAt(plural.length() - 1)) {
    return plural.substring(0, plural.length() - 1);
...
Stringsingularise(String name)
singularise
String result = name;
if (seemsPluralised(name)) {
    String lower = name.toLowerCase();
    if (lower.endsWith("ies")) {
        result = name.substring(0, name.length() - 3) + "y";
    } else if (lower.endsWith("ches") || lower.endsWith("ses")) {
        result = name.substring(0, name.length() - 2);
    } else if (lower.endsWith("s")) {
...
Stringsingularize(final String buffer)
singularize
String singular = null;
if (buffer == null) {
    return singular;
final int length = buffer.length();
if (buffer.endsWith("ies")) {
    singular = buffer.substring(0, length - 3);
} else if (buffer.endsWith("es")) {
...
Stringsingularize(String value)
singularize
return value.substring(0, value.length() - 1);
StringsingularOrPlural(int testValue, String singular, String plural)
Returns the singular or plural string based on the test value
if (testValue == 1)
    return (singular);
return (plural);
StringsingularPlural(int n, String singular, String plural)
singular Plural
if (n < 0) {
    throw new IllegalArgumentException("n = " + n + " < 0");
return n + " " + (n <= 1 ? singular : plural);
StringSingularToPlural(String noun)
Singular To Plural
String[] ExceptionWords_DirectAddS = { "canto", "solo", "piano", "lasso", "halo", "memento", "albino",
        "sirocco", "chief", "fife", "mischief", "hoof", "roof", "grief", "kerchief", "safe" };
String[] ExceptionWords_IrregularInput = { "man", "foot", "mouse", "woman", "tooth", "louse", "child", "ox",
        "goose" };
String[] ExceptionWords_IrregularOutput = { "men", "feet", "mice", "women", "teeth", "lice", "children",
        "oxen", "geese" };
String[] ExceptionWords_NoPlural = { "gold", "silver", "wheat", "corn", "molasses", "copper", "sugar",
        "cotton", "USA" };
...