String
singular(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);
...
String
singularise(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")) {
...
String
SingularToPlural(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" };
...