use of edu.illinois.cs.cogcomp.ner.LbjTagger.Data in project cogcomp-nlp by CogComp.
the class ReferenceUtils method createNerDataStructuresForText.
public Data createNerDataStructuresForText(TextAnnotation ta) {
ArrayList<LinkedVector> sentences = new ArrayList<>();
String[] tokens = ta.getTokens();
int[] tokenindices = new int[tokens.length];
int tokenIndex = 0;
int neWordIndex = 0;
for (int i = 0; i < ta.getNumberOfSentences(); i++) {
Sentence sentence = ta.getSentence(i);
String[] wtoks = sentence.getTokens();
LinkedVector words = new LinkedVector();
for (String w : wtoks) {
if (w.length() > 0) {
NEWord.addTokenToSentence(words, w, "unlabeled");
tokenindices[neWordIndex] = tokenIndex;
neWordIndex++;
} else {
throw new IllegalStateException("Bad (zero length) token.");
}
tokenIndex++;
}
if (words.size() > 0)
sentences.add(words);
}
// Do the annotation.
Data data = new Data(new NERDocument(sentences, "input"));
return data;
}
Aggregations