diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2018-10-14 14:08:52 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2018-10-14 14:08:52 -0400 |
| commit | b09885e13d8829ee59e10ec0a957f6209c3e4aeb (patch) | |
| tree | 8332f1d37a6df8ca68c2912fe4f7372af7ab455c | |
| parent | f8eff578b94fece2d02a15104b540537c2a6d0cc (diff) | |
Update
| -rw-r--r-- | src/examples/java/bjc/inflexion/examples/IndefTester.java | 9 | ||||
| -rw-r--r-- | src/main/java/bjc/inflexion/EnglishUtils.java | 14 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/examples/java/bjc/inflexion/examples/IndefTester.java b/src/examples/java/bjc/inflexion/examples/IndefTester.java index fd1929c..e22737c 100644 --- a/src/examples/java/bjc/inflexion/examples/IndefTester.java +++ b/src/examples/java/bjc/inflexion/examples/IndefTester.java @@ -4,7 +4,16 @@ import java.util.Scanner; import bjc.inflexion.EnglishUtils; +/** + * Test class for checking indefinite articles + * @author bjculkin + * + */ public class IndefTester { + /** + * Main method. + * @param args Unused CLI args. + */ public static void main(String[] args) { Scanner scn = new Scanner(System.in); diff --git a/src/main/java/bjc/inflexion/EnglishUtils.java b/src/main/java/bjc/inflexion/EnglishUtils.java index 197b7cf..1a399be 100644 --- a/src/main/java/bjc/inflexion/EnglishUtils.java +++ b/src/main/java/bjc/inflexion/EnglishUtils.java @@ -74,7 +74,11 @@ public class EnglishUtils { return "many"; } - + /** + * Pick an indefinite article ('a' or 'an') for a phrase. + * @param phrase The phrase to pick an article for. + * @return The article to use for the phrase. + */ public static String pickIndefinite(String phrase) { Pattern pattern; Matcher matcher; @@ -112,9 +116,9 @@ public class EnglishUtils { if (lowercaseWord.length() == 1) { if ("aedhilmnorsx".indexOf(lowercaseWord) >= 0) { return "an"; - } else { - return "a"; } + + return "a"; } // Capital words which should likely be preceded by 'an' @@ -137,9 +141,9 @@ public class EnglishUtils { } else if (word == word.toUpperCase()) { if ("aedhilmnorsx".indexOf(lowercaseWord.substring(0, 1)) >= 0) { return "an"; - } else { - return "a"; } + + return "a"; } // Basic method of words that begin with a vowel being preceded by 'an' |
