use of eu.clarin.weblicht.wlfxb.tc.api.PosTagsLayer in project webanno by webanno.
the class TcfWriter method writePosTags.
private void writePosTags(JCas aJCas, TextCorpus aTextCorpus, Map<Integer, eu.clarin.weblicht.wlfxb.tc.api.Token> aTokensBeginPositionMap) {
if (!JCasUtil.exists(aJCas, POS.class)) {
// Do nothing if there are no part-of-speech tags in the CAS
getLogger().debug("Layer [" + TextCorpusLayerTag.POSTAGS.getXmlName() + "]: empty");
return;
}
// Tokens layer must already exist
TokensLayer tokensLayer = aTextCorpus.getTokensLayer();
// create POS tag annotation layer
String posTagSet = "STTS";
for (TagsetDescription tagSet : select(aJCas, TagsetDescription.class)) {
if (tagSet.getLayer().equals(POS.class.getName())) {
posTagSet = tagSet.getName();
break;
}
}
PosTagsLayer posLayer = aTextCorpus.createPosTagsLayer(posTagSet);
getLogger().debug("Layer [" + TextCorpusLayerTag.POSTAGS.getXmlName() + "]: created");
int j = 0;
for (Token coveredToken : select(aJCas, Token.class)) {
POS pos = coveredToken.getPos();
if (pos != null && posLayer != null) {
String posValue = coveredToken.getPos().getPosValue();
posLayer.addTag(posValue, tokensLayer.getToken(j));
}
j++;
}
}
Aggregations