Search in sources :

Example 1 with OrthographyLayer

use of eu.clarin.weblicht.wlfxb.tc.api.OrthographyLayer in project webanno by webanno.

the class TcfWriter method writeOrthograph.

private void writeOrthograph(JCas aJCas, TextCorpus aTextCorpus) {
    if (!JCasUtil.exists(aJCas, SofaChangeAnnotation.class)) {
        // Do nothing if there are no SofaChangeAnnotation layer
        // (Which is equivalent to Orthography layer in TCF) in the CAS
        getLogger().debug("Layer [" + TextCorpusLayerTag.ORTHOGRAPHY.getXmlName() + "]: empty");
        return;
    }
    // Tokens layer must already exist
    TokensLayer tokensLayer = aTextCorpus.getTokensLayer();
    // create orthographyLayer annotation layer
    OrthographyLayer orthographyLayer = aTextCorpus.createOrthographyLayer();
    getLogger().debug("Layer [" + TextCorpusLayerTag.ORTHOGRAPHY.getXmlName() + "]: created");
    int j = 0;
    for (Token token : select(aJCas, Token.class)) {
        List<SofaChangeAnnotation> scas = selectCovered(aJCas, SofaChangeAnnotation.class, token.getBegin(), token.getEnd());
        if (scas.size() > 0 && orthographyLayer != null) {
            orthographyLayer.addCorrection(scas.get(0).getValue(), tokensLayer.getToken(j), CorrectionOperation.valueOf(scas.get(0).getOperation()));
        }
        j++;
    }
}
Also used : SofaChangeAnnotation(de.tudarmstadt.ukp.dkpro.core.api.transform.type.SofaChangeAnnotation) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) TokensLayer(eu.clarin.weblicht.wlfxb.tc.api.TokensLayer) OrthographyLayer(eu.clarin.weblicht.wlfxb.tc.api.OrthographyLayer)

Aggregations

Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)1 SofaChangeAnnotation (de.tudarmstadt.ukp.dkpro.core.api.transform.type.SofaChangeAnnotation)1 OrthographyLayer (eu.clarin.weblicht.wlfxb.tc.api.OrthographyLayer)1 TokensLayer (eu.clarin.weblicht.wlfxb.tc.api.TokensLayer)1