use of eu.clarin.weblicht.wlfxb.tc.api.LemmasLayer in project webanno by webanno.
the class TcfWriter method writeLemmas.
private void writeLemmas(JCas aJCas, TextCorpus aTextCorpus, Map<Integer, eu.clarin.weblicht.wlfxb.tc.api.Token> aTokensBeginPositionMap) {
if (!JCasUtil.exists(aJCas, Lemma.class)) {
// Do nothing if there are no lemmas in the CAS
getLogger().debug("Layer [" + TextCorpusLayerTag.LEMMAS.getXmlName() + "]: empty");
return;
}
// Tokens layer must already exist
TokensLayer tokensLayer = aTextCorpus.getTokensLayer();
// create lemma annotation layer
LemmasLayer lemmasLayer = aTextCorpus.createLemmasLayer();
getLogger().debug("Layer [" + TextCorpusLayerTag.LEMMAS.getXmlName() + "]: created");
int j = 0;
for (Token coveredToken : select(aJCas, Token.class)) {
Lemma lemma = coveredToken.getLemma();
if (lemma != null && lemmasLayer != null) {
String lemmaValue = coveredToken.getLemma().getValue();
lemmasLayer.addLemma(lemmaValue, tokensLayer.getToken(j));
}
j++;
}
}
Aggregations