NameSample { @Override public String toString() { StringBuilder result = new StringBuilder(); if (isClearAdaptiveDataSet()) result.append("\n"); for (int tokenIndex = 0; tokenIndex < sentence.size(); tokenIndex++) { for (Span name : names) { if (name.getStart() == tokenIndex) { if (name.getType() == null) { result.append(NameSampleDataStream.START_TAG).append(' '); } else { result.append(NameSampleDataStream.START_TAG_PREFIX).append(name.getType()).append("> "); } } if (name.getEnd() == tokenIndex) { result.append(NameSampleDataStream.END_TAG).append(' '); } } result.append(sentence.get(tokenIndex)).append(' '); } if (sentence.size() > 1) result.setLength(result.length() - 1); for (Span name : names) { if (name.getEnd() == sentence.size()) { result.append(' ').append(NameSampleDataStream.END_TAG); } } return result.toString(); } NameSample(String[] sentence, Span[] names,
      String[][] additionalContext, boolean clearAdaptiveData);  NameSample(String[] sentence, Span[] names, boolean clearAdaptiveData); String[] getSentence(); Span[] getNames(); String[][] getAdditionalContext(); boolean isClearAdaptiveDataSet(); @Override boolean equals(Object obj); @Override String toString(); static NameSample parse(String taggedTokens,
      boolean isClearAdaptiveData); static NameSample parse(String taggedTokens, String defaultType,
      boolean isClearAdaptiveData); static final String DEFAULT_TYPE; }
@Test public void testNoTypesToString() { String nameSampleStr = createSimpleNameSample(false).toString(); assertEquals("<START> U . S . <END> President <START> Barack Obama <END> is considering " + "sending additional American forces to <START> Afghanistan <END> .", nameSampleStr); }
@Test public void testNameAtEnd() { String sentence[] = new String[] { "My", "name", "is", "Anna" }; NameSample sample = new NameSample(sentence, new Span[]{new Span(3, 4)}, false); assertEquals("My name is <START> Anna <END>", sample.toString()); }