use of eu.clarin.weblicht.wlfxb.tc.api.NamedEntitiesLayer in project webanno by webanno.
the class TcfWriter method writeNamedEntity.
private void writeNamedEntity(JCas aJCas, TextCorpus aTextCorpus, Map<Integer, eu.clarin.weblicht.wlfxb.tc.api.Token> aTokensBeginPositionMap) {
if (!JCasUtil.exists(aJCas, NamedEntity.class)) {
// Do nothing if there are no named entities in the CAS
getLogger().debug("Layer [" + TextCorpusLayerTag.NAMED_ENTITIES.getXmlName() + "]: empty");
return;
}
String tagSetName = "BART";
for (TagsetDescription tagSet : select(aJCas, TagsetDescription.class)) {
if (tagSet.getLayer().equals(NamedEntity.class.getName())) {
tagSetName = tagSet.getName();
break;
}
}
NamedEntitiesLayer namedEntitiesLayer = aTextCorpus.createNamedEntitiesLayer(tagSetName);
getLogger().debug("Layer [" + TextCorpusLayerTag.NAMED_ENTITIES.getXmlName() + "]: created");
for (NamedEntity namedEntity : select(aJCas, NamedEntity.class)) {
List<Token> tokensInCas = selectCovered(aJCas, Token.class, namedEntity.getBegin(), namedEntity.getEnd());
List<eu.clarin.weblicht.wlfxb.tc.api.Token> tokensInTcf = new ArrayList<>();
for (Token token : tokensInCas) {
tokensInTcf.add(aTokensBeginPositionMap.get(token.getBegin()));
}
namedEntitiesLayer.addEntity(namedEntity.getValue(), tokensInTcf);
}
}
Aggregations