import java.util.HashSet; import java.util.LinkedList; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Transforms words to singular, plural, humanized (human readable), underscore, camel case, or ordinal form. This is inspired by * the Inflector class in Ruby on Rails , which is distributed under the Rails license . * @author Randall Hauch * */ public class Inflector { protected static final Inflector INSTANCE = new Inflector(); public static final Inflector getInstance() { return INSTANCE; } protected class Rule { protected final String expression; protected final Pattern expressionPattern; protected final String replacement; protected Rule(String expression, String replacement) { this.expression = expression; this.replacement = replacement != null ? replacement : ""; this.expressionPattern = Pattern.compile(this.expression, Pattern.CASE_INSENSITIVE); }...