POSSample { public static POSSample parse(String sentenceString) throws InvalidFormatException { String tokenTags[] = WhitespaceTokenizer.INSTANCE.tokenize(sentenceString); String sentence[] = new String[tokenTags.length]; String tags[] = new String[tokenTags.length]; for (int i = 0; i < tokenTags.length; i++) { int split = tokenTags[i].lastIndexOf("_"); if (split == -1) { throw new InvalidFormatException("Cannot find \"_\" inside token '" + tokenTags[i] + "'!"); } sentence[i] = tokenTags[i].substring(0, split); tags[i] = tokenTags[i].substring(split+1); } return new POSSample(sentence, tags); } POSSample(String sentence[], String tags[]);  POSSample(List<String> sentence, List<String> tags);  POSSample(List<String> sentence, List<String> tags,
      String[][] additionalContext);  POSSample(String sentence[], String tags[],
      String[][] additionalContext); String[] getSentence(); String[] getTags(); String[][] getAddictionalContext(); @Override String toString(); static POSSample parse(String sentenceString); @Override boolean equals(Object obj);  }
@Test public void testParse() throws InvalidFormatException { String sentence = "the_DT stories_NNS about_IN well-heeled_JJ " + "communities_NNS and_CC developers_NNS"; POSSample sample = POSSample.parse(sentence); assertEquals(sentence, sample.toString()); }
@Test public void testParseWithError() { String sentence = "the_DT stories"; try { POSSample.parse(sentence); } catch (InvalidFormatException e) { return; } fail(); }