summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/inflexion/EnglishUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/bjc/inflexion/EnglishUtils.java')
-rw-r--r--src/main/java/bjc/inflexion/EnglishUtils.java50
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
+}