protected String getNERString() { List<Constituent> constituents = new ArrayList<>(view.getConstituents()); Collections.sort(constituents, TextAnnotationUtilities.constituentStartComparator); StringBuilder sb = new StringBuilder(); String text = textAnnotation.getText(); int where = 0; for (Constituent c : constituents) { int start = c.getStartCharOffset(); String startstring = text.substring(where, start); sb.append(startstring) .append("[") .append(c.getLabel()) .append(" ") .append(c.getTokenizedSurfaceForm()) .append(" ] "); where = c.getEndCharOffset(); } return sb.toString(); }