use of de.tudarmstadt.ukp.dkpro.core.api.transform.type.SofaChangeAnnotation 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++;
}
}
use of de.tudarmstadt.ukp.dkpro.core.api.transform.type.SofaChangeAnnotation in project webanno by webanno.
the class TcfReader method convertOrthoGraphy.
private void convertOrthoGraphy(JCas aJCas, TextCorpus aCorpusData, Map<String, Token> aTokens) {
if (aCorpusData.getOrthographyLayer() == null) {
return;
}
for (int i = 0; i < aCorpusData.getOrthographyLayer().size(); i++) {
eu.clarin.weblicht.wlfxb.tc.api.Token[] orthoTokens = aCorpusData.getOrthographyLayer().getTokens(aCorpusData.getOrthographyLayer().getCorrection(i));
String value = aCorpusData.getOrthographyLayer().getCorrection(i).getString();
String operation = aCorpusData.getOrthographyLayer().getCorrection(i).getOperation().name();
SofaChangeAnnotation ortho = new SofaChangeAnnotation(aJCas);
ortho.setBegin(aTokens.get(orthoTokens[0].getID()).getBegin());
ortho.setEnd(aTokens.get(orthoTokens[0].getID()).getEnd());
ortho.setValue(value);
ortho.setOperation(operation);
ortho.addToIndexes();
}
}
Aggregations