use of eu.clarin.weblicht.wlfxb.tc.api.DependencyParsingLayer in project webanno by webanno.
the class TcfWriter method writeDependency.
private void writeDependency(JCas aJCas, TextCorpus aTextCorpus, Map<Integer, eu.clarin.weblicht.wlfxb.tc.api.Token> aTokensBeginPositionMap) {
if (!JCasUtil.exists(aJCas, Dependency.class)) {
// Do nothing if there are no dependencies in the CAS
getLogger().debug("Layer [" + TextCorpusLayerTag.PARSING_DEPENDENCY.getXmlName() + "]: empty");
return;
}
DependencyParsingLayer dependencyParsingLayer = null;
String tagSetName = "tiger";
for (TagsetDescription tagSet : select(aJCas, TagsetDescription.class)) {
if (tagSet.getLayer().equals(Dependency.class.getName())) {
tagSetName = tagSet.getName();
break;
}
}
dependencyParsingLayer = aTextCorpus.createDependencyParsingLayer(tagSetName, false, true);
getLogger().debug("Layer [" + TextCorpusLayerTag.PARSING_DEPENDENCY.getXmlName() + "]: created");
for (Sentence s : select(aJCas, Sentence.class)) {
List<eu.clarin.weblicht.wlfxb.tc.api.Dependency> deps = new ArrayList<>();
for (Dependency d : selectCovered(Dependency.class, s)) {
eu.clarin.weblicht.wlfxb.tc.api.Dependency dependency = dependencyParsingLayer.createDependency(d.getDependencyType(), aTokensBeginPositionMap.get(d.getDependent().getBegin()), aTokensBeginPositionMap.get(d.getGovernor().getBegin()));
deps.add(dependency);
}
if (deps.size() > 0) {
dependencyParsingLayer.addParse(deps);
}
}
}
Aggregations