Search in sources :

Example 1 with PosTagsLayer

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++;
    }
}
Also used : POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) PosTagsLayer(eu.clarin.weblicht.wlfxb.tc.api.PosTagsLayer) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) TokensLayer(eu.clarin.weblicht.wlfxb.tc.api.TokensLayer) TagsetDescription(de.tudarmstadt.ukp.dkpro.core.api.metadata.type.TagsetDescription)

Aggregations

POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)1 TagsetDescription (de.tudarmstadt.ukp.dkpro.core.api.metadata.type.TagsetDescription)1 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)1 PosTagsLayer (eu.clarin.weblicht.wlfxb.tc.api.PosTagsLayer)1 TokensLayer (eu.clarin.weblicht.wlfxb.tc.api.TokensLayer)1