TreebankFormatParser { public static String getType(String parseFragment) { Matcher typeMatcher = typePattern.matcher(parseFragment); if (typeMatcher.find()) return typeMatcher.group(1); return null; }  static TreebankNode getLeafNode(String parseFragment); static String getType(String parseFragment); static String prepareString(String parse); static String inferPlainText(String treebankText); static TopTreebankNode parse(String parse); static TopTreebankNode parse(String parse, String text, int textOffset); static int movePastWhiteSpaceChars(String text, int textOffset); static String[] splitSentences(String mrgContents); static boolean parensMatch(String contents); static List<TopTreebankNode> parseDocument(String parse, int textOffset, String text); static final String LEAF_NODE_REGEX; static final String TYPE_REGEX; static final String cleanUPRegex1; static final String cleanUPRegex2; static final String cleanUPRegex3; static final String cleanUPRegex4; }
@Test public void testGetType() { String type = TreebankFormatParser.getType("(ASDF)"); assertEquals("ASDF", type); type = TreebankFormatParser.getType("(-RRB- -RCB-)"); assertEquals("-RRB-", type); type = TreebankFormatParser.getType("(NNP Community)"); assertEquals("NNP", type); type = TreebankFormatParser.getType("(: --)"); assertEquals(":", type); type = TreebankFormatParser.getType("(NP-LOC (NNP CA) )"); assertEquals("NP-LOC", type); type = TreebankFormatParser.getType("(NP"); assertEquals("NP", type); type = TreebankFormatParser.getType("(-NONE- *U*) ) (PP (IN of)"); assertEquals("-NONE-", type); type = TreebankFormatParser.getType("((-NONE- *U*) ) (PP (IN of)"); assertEquals(null, type); }