Search in sources :

Example 1 with DependencyParsingLayer

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

Aggregations

TagsetDescription (de.tudarmstadt.ukp.dkpro.core.api.metadata.type.TagsetDescription)1 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)1 Dependency (de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency)1 DependencyParsingLayer (eu.clarin.weblicht.wlfxb.tc.api.DependencyParsingLayer)1 ArrayList (java.util.ArrayList)1