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++;
}
}
Aggregations