diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-11 21:34:29 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-11 21:34:29 -0300 |
| commit | 235208946ceb2bf0f422956a3ebc0ebb88ba28b6 (patch) | |
| tree | e50faa94428972c6c23a605ffb4ec88d28f73cba /src/main/java/bjc/inflexion/EnglishUtils.java | |
| parent | 46cb1f6c030991d314d0ef1fafa53e53ef3e03c9 (diff) | |
Cleanup
Diffstat (limited to 'src/main/java/bjc/inflexion/EnglishUtils.java')
| -rw-r--r-- | src/main/java/bjc/inflexion/EnglishUtils.java | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/src/main/java/bjc/inflexion/EnglishUtils.java b/src/main/java/bjc/inflexion/EnglishUtils.java index 3feb55b..28fc6c6 100644 --- a/src/main/java/bjc/inflexion/EnglishUtils.java +++ b/src/main/java/bjc/inflexion/EnglishUtils.java @@ -16,37 +16,27 @@ package bjc.inflexion; /** - * @author student + * General utils for dealing with english. * + * @author student */ public class EnglishUtils { - private static String[] smallNums = new String[] { "zero", "one", "two", "three", "four", "five", "six", - "seven", "eight", "nine", "ten" - }; + private static String[] smallNums = new String[] { + "zero", "one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", "ten" }; - private static String[] summaryNums = new String[] { "no", "one", "a couple of", "a few", "several" }; - private static String[] endSummaryNums = new String[] { "no", "one", "a couple of", "a few", "several" }; + private static String[] summaryNums = new String[] { "no", "one", "a couple of", "a few", "several" }; private static int[] summaryMap = new int[] { - /* - * no - */ + /* no */ 0, - /* - * one - */ + /* one */ 1, - /* - * a couple of - */ + /* a couple of */ 2, - /* - * a few - */ + /* a few */ 3, 3, 3, - /* - * several - */ + /* several */ 4, 4, 4, 4 }; @@ -54,9 +44,10 @@ public class EnglishUtils { * Convert small integers to words. * * @param num - * The number to convert. + * The number to convert. * - * @return The word for the number, if it's less than ten. + * @return + * The word for the number, if it's less than ten. */ public static String smallIntToWord(final int num) { if (num >= 0 && num <= 10) return smallNums[num]; @@ -68,18 +59,17 @@ public class EnglishUtils { * Summarize an integer. * * @param num - * The number to summarize. + * The number to summarize. * * @param atEnd - * Whether or not the integer is at the end of a string. + * Whether or not the integer is at the end of a string. * - * @return A string summarizing the integer. + * @return + * A string summarizing the integer. */ public static String intSummarize(final int num, final boolean atEnd) { - final String[] nums = atEnd ? endSummaryNums : summaryNums; - - if (num >= 0 && num < 10) return nums[summaryMap[num]]; + if (num >= 0 && num < 10) return summaryNums[summaryMap[num]]; return "many"; } -}
\ No newline at end of file +} |
