Search in sources :

Example 1 with SentencesLayer

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);
    }
}
Also used : SentencesLayer(eu.clarin.weblicht.wlfxb.tc.api.SentencesLayer) ArrayList(java.util.ArrayList) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) Sentence(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)

Aggregations

Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)1 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)1 SentencesLayer (eu.clarin.weblicht.wlfxb.tc.api.SentencesLayer)1 ArrayList (java.util.ArrayList)1