ChunkSample { public String nicePrint() { Span[] spans = getPhrasesAsSpanList(); StringBuilder result = new StringBuilder(" "); for (int tokenIndex = 0; tokenIndex < sentence.size(); tokenIndex++) { for (int nameIndex = 0; nameIndex < spans.length; nameIndex++) { if (spans[nameIndex].getStart() == tokenIndex) { result.append("[").append(spans[nameIndex].getType()).append(" "); } if (spans[nameIndex].getEnd() == tokenIndex) { result.append("]").append(' '); } } result.append(sentence.get(tokenIndex)).append("_").append(tags.get(tokenIndex)).append(' '); } if (sentence.size() > 1) result.setLength(result.length() - 1); for (int nameIndex = 0; nameIndex < spans.length; nameIndex++) { if (spans[nameIndex].getEnd() == sentence.size()) { result.append(']'); } } return result.toString(); } ChunkSample(String[] sentence, String[] tags, String[] preds);  ChunkSample(List<String> sentence, List<String> tags, List<String> preds); String[] getSentence(); String[] getTags(); String[] getPreds(); Span[] getPhrasesAsSpanList(); static Span[] phrasesAsSpanList(String[] aSentence, String[] aTags,
      String[] aPreds); String nicePrint(); @Override String toString(); @Override boolean equals(Object obj);  }
@Test public void testNicePrint() { ChunkSample sample = new ChunkSample(createSentence(), createTags(), createChunks()); assertEquals(" [NP Forecasts_NNS ] [PP for_IN ] [NP the_DT trade_NN figures_NNS ] " + "[VP range_VBP ] [ADVP widely_RB ] ,_, [NP Forecasts_NNS ] [PP for_IN ] [NP the_DT trade_NN figures_NNS ] " + "[VP range_VBP ] [ADVP widely_RB ] ._.", sample.nicePrint()); }