}
private static final String SPACE_HOLDER = "##";
private static CoreLabel loadToken(String line, boolean haveExplicitAntecedent) {
CoreLabel token = new CoreLabel();
String [] bits = line.split("\t", -1);
if(bits.length < 7) throw new RuntimeIOException("ERROR: Invalid format token for serialized token (only " + bits.length + " tokens): " + line);
// word
String word = bits[0].replaceAll(SPACE_HOLDER, " ");
token.set(CoreAnnotations.TextAnnotation.class, word);
token.set(CoreAnnotations.ValueAnnotation.class, word);
// if(word.length() == 0) System.err.println("FOUND 0-LENGTH TOKEN!");
// lemma
if(bits[1].length() > 0 || bits[0].length() == 0){
String lemma = bits[1].replaceAll(SPACE_HOLDER, " ");
token.set(CoreAnnotations.LemmaAnnotation.class, lemma);
}
// POS tag
if(bits[2].length() > 0) token.set(CoreAnnotations.PartOfSpeechAnnotation.class, bits[2]);
// NE tag
if(bits[3].length() > 0) token.set(CoreAnnotations.NamedEntityTagAnnotation.class, bits[3]);
// Normalized NE tag
if(bits[4].length() > 0) token.set(CoreAnnotations.NormalizedNamedEntityTagAnnotation.class, bits[4]);
// Character offsets
if(bits[5].length() > 0) token.set(CoreAnnotations.CharacterOffsetBeginAnnotation.class, Integer.parseInt(bits[5]));
if(bits[6].length() > 0) token.set(CoreAnnotations.CharacterOffsetEndAnnotation.class, Integer.parseInt(bits[6]));
if(haveExplicitAntecedent){
// This block is specific to KBP
// We may have AntecedentAnnotation
if(bits.length > 7){
String aa = bits[7].replaceAll(SPACE_HOLDER, " ");
if(aa.length() > 0) token.set(CoreAnnotations.AntecedentAnnotation.class, aa);
}
}
return token;
}