FlorestaTagInterpreter implements TagInterpreterI { public MorphologicalTag parseMorphologicalTag(String tagString) { if (tagString == null) { return null; } synchronized (cache) { if (cache.containsKey(tagString)) { return ((MorphologicalTag) cache.get(tagString)).clone(); } } MorphologicalTag m = new MorphologicalTag(); String[] tags = tagString.split(SEP); for (String tag : tags) { if (MTAG_PARTS_ENUM.containsKey(tag)) { List<Enum<?>> tagE = MTAG_PARTS_ENUM.get(tag); for (Enum<?> t : tagE) { if (t instanceof Class) { m.setClazz((Class) t); } else if (t instanceof Gender) { m.setGender((Gender) t); } else if (t instanceof Number) { m.setNumber((Number) t); } else if (t instanceof Case) { m.setCase((Case) t); } else if (t instanceof Person) { m.setPerson((Person) t); } else if (t instanceof Tense) { m.setTense((Tense) t); } else if (t instanceof Mood) { m.setMood((Mood) t); } else if (t instanceof Finiteness) { m.setFiniteness((Finiteness) t); } else if (t instanceof Punctuation) { m.setPunctuation((Punctuation) t); } } } else { if (tag.length() == 1) { m.setClazz(Class.PUNCTUATION_MARK); } else if ("n:".equals(tag)) { m.setClazz(Class.NOUN); } else if ("pp".equals(tag)) { m.setClazz(Class.PREPOSITION); } else if ("np".equals(tag)) { m.setClazz(Class.NOUN); } else if ("vp".equals(tag)) { m.setClazz(Class.VERB); } else if (tag.contains("<") || "P.vp".equals(tag) || "GER".equals(tag)) { } else { LOGGER.warn("Could not parse tag: " + tag); } } } if (m.toString() == null || m.toString().length() == 0) { LOGGER.error("Invalid MorphologicalTag: " + tagString); } synchronized (cache) { if (!cache.containsKey(tagString)) { cache.put(tagString, m.clone()); } } return m; } FlorestaTagInterpreter(); MorphologicalTag parseMorphologicalTag(String tagString); ChunkTag parseChunkTag(String tagString); SyntacticTag parseSyntacticTag(String tagString); String serialize(MorphologicalTag tag); String serialize(ChunkTag tag); String serialize(SyntacticTag tag); String serialize(SyntacticFunction tag); String serialize(ChunkFunction tag); String serialize(Class tag); String serialize(Gender tag); String serialize(Number tag); String serialize(Case tag); String serialize(Person tag); String serialize(Tense tag); String serialize(Mood tag); String serialize(Finiteness tag); String serialize(Punctuation tag);  }
@Test public void testParseMorphologicalTag() { for (String tag : table.keySet()) { if (table.get(tag) != null) assertEquals("Failed to parse class tag: " + tag, table.get(tag), ti .parseMorphologicalTag(tag).getClazzE()); } }
@Test public void testPunctuation() { MorphologicalTag mt = ti.parseMorphologicalTag("."); assertEquals(Class.PUNCTUATION_MARK, mt.getClazzE()); assertEquals(Punctuation.ABS, mt.getPunctuation()); mt = ti.parseMorphologicalTag("!"); assertEquals(Class.PUNCTUATION_MARK, mt.getClazzE()); assertEquals(Punctuation.ABS, mt.getPunctuation()); mt = ti.parseMorphologicalTag("?"); assertEquals(Class.PUNCTUATION_MARK, mt.getClazzE()); assertEquals(Punctuation.ABS, mt.getPunctuation()); mt = ti.parseMorphologicalTag(","); assertEquals(Class.PUNCTUATION_MARK, mt.getClazzE()); assertEquals(Punctuation.NSEP, mt.getPunctuation()); mt = ti.parseMorphologicalTag(";"); assertEquals(Class.PUNCTUATION_MARK, mt.getClazzE()); assertEquals(Punctuation.REL, mt.getPunctuation()); mt = ti.parseMorphologicalTag("("); assertEquals(Class.PUNCTUATION_MARK, mt.getClazzE()); assertEquals(Punctuation.BIN, mt.getPunctuation()); mt = ti.parseMorphologicalTag("--"); assertEquals(Class.PUNCTUATION_MARK, mt.getClazzE()); assertEquals(Punctuation.BIN, mt.getPunctuation()); mt = ti.parseMorphologicalTag("..."); assertEquals(Class.PUNCTUATION_MARK, mt.getClazzE()); assertEquals(Punctuation.REL, mt.getPunctuation()); mt = ti.parseMorphologicalTag("«"); assertEquals(Class.PUNCTUATION_MARK, mt.getClazzE()); assertEquals(Punctuation.NSEP, mt.getPunctuation()); mt = ti.parseMorphologicalTag("v-pcp"); assertEquals(Class.VERB, mt.getClazzE()); assertEquals(Finiteness.PARTICIPLE, mt.getFinitenessE()); mt = ti.parseMorphologicalTag("v-inf"); assertEquals(Class.VERB, mt.getClazzE()); assertEquals(Finiteness.INFINITIVE, mt.getFinitenessE()); mt = ti.parseMorphologicalTag("v-ger"); assertEquals(Class.VERB, mt.getClazzE()); assertEquals(Finiteness.GERUND, mt.getFinitenessE()); mt = ti.parseMorphologicalTag("v-fin"); assertEquals(Class.VERB, mt.getClazzE()); assertEquals(Finiteness.FINITE, mt.getFinitenessE()); mt = ti.parseMorphologicalTag("n-adj"); assertEquals(Class.ADJECTIVE, mt.getClazzE()); mt = ti.parseMorphologicalTag("intj"); assertEquals(Class.INTERJECTION, mt.getClazzE()); }