use of eu.clarin.weblicht.wlfxb.tc.api.SentencesLayer in project webanno by webanno.
the class TcfWriter method writeSentence.
private void writeSentence(JCas aJCas, TextCorpus aTextCorpus, Map<Integer, eu.clarin.weblicht.wlfxb.tc.api.Token> aTokensBeginPositionMap) {
// if not TCF file, add sentence layer (Sentence is required for BRAT)
SentencesLayer sentencesLayer = aTextCorpus.getSentencesLayer();
if (sentencesLayer != null) {
getLogger().debug("Layer [" + TextCorpusLayerTag.SENTENCES.getXmlName() + "]: found");
return;
}
sentencesLayer = aTextCorpus.createSentencesLayer();
getLogger().debug("Layer [" + TextCorpusLayerTag.SENTENCES.getXmlName() + "]: created");
for (Sentence sentence : select(aJCas, Sentence.class)) {
List<eu.clarin.weblicht.wlfxb.tc.api.Token> tokens = new ArrayList<>();
for (Token token : selectCovered(Token.class, sentence)) {
tokens.add(aTokensBeginPositionMap.get(token.getBegin()));
}
sentencesLayer.addSentence(tokens);
}
}
Aggregations