WordNetUtils { public static POS toPos(String pos) { final String lc = pos.toLowerCase(); POS ret = null; if (lc.startsWith("n")) { ret = POS.NOUN; } else if (lc.startsWith("v")) { ret = POS.VERB; } else if (lc.startsWith("r") || lc.startsWith("adv")) { ret = POS.ADVERB; } else if (lc.startsWith("j") || lc.startsWith("adj")) { ret = POS.ADJECTIVE; } return ret; } private  WordNetUtils(); static POS toPos(String pos);  }
@Test public void testToPos() { assertEquals(POS.VERB, WordNetUtils.toPos("verb")); assertEquals(POS.VERB, WordNetUtils.toPos("vbz")); assertEquals(POS.NOUN, WordNetUtils.toPos("nns")); assertEquals(POS.ADVERB, WordNetUtils.toPos("r")); assertEquals(POS.ADVERB, WordNetUtils.toPos("adv")); assertEquals(POS.ADJECTIVE, WordNetUtils.toPos("j")); assertEquals(POS.ADJECTIVE, WordNetUtils.toPos("adj")); assertEquals(null, WordNetUtils.toPos("somethingelse")); }