From a0c39c970c4086b6067314c0b577c2ad4d74398e Mon Sep 17 00:00:00 2001 From: dhowe Date: Tue, 18 Apr 2017 17:05:03 +0800 Subject: [PATCH] fixed to pass tests #409 --- java/rita/RiLexicon.java | 18 ++++++++++++------ java/rita/test/RiLexiconTest.java | 1 - 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/java/rita/RiLexicon.java b/java/rita/RiLexicon.java index 4debc763..6de24eaa 100755 --- a/java/rita/RiLexicon.java +++ b/java/rita/RiLexicon.java @@ -188,13 +188,19 @@ public String randomWord(int syllableCount) { */ public String randomWord(String pos, int syllableCount) { - boolean pluralize = pos.equals("nns"); + boolean pluralize = false; - if (pos.equals("v")) pos = "vb"; - if (pos.equals("r")) pos = "rb"; - if (pos.equals("a")) pos = "jj"; - if (pos.equals("n") || pos.equals("nns")) - pos = "nn"; + if (pos != null) { + pluralize = pos.equals("nns"); + if (pos.equals("v")) + pos = "vb"; + if (pos.equals("r")) + pos = "rb"; + if (pos.equals("a")) + pos = "jj"; + if (pos.equals("n") || pos.equals("nns")) + pos = "nn"; + } Iterator it = getIterator(pos); diff --git a/java/rita/test/RiLexiconTest.java b/java/rita/test/RiLexiconTest.java index 0a326fe5..aa412fb1 100644 --- a/java/rita/test/RiLexiconTest.java +++ b/java/rita/test/RiLexiconTest.java @@ -211,7 +211,6 @@ public void testLexicalData() { @Test public void testRandomWord() { - RiLexicon lex = new RiLexicon(); String result = lex.randomWord();