Search in sources :

Example 1 with OffsetsList

use of de.tudarmstadt.ukp.clarin.webanno.brat.render.model.OffsetsList in project webanno by webanno.

the class BratAnnotationEditor method getOffsetsFromRequest.

/**
 * Extract offset information from the current request. These are either offsets of an existing
 * selected annotations or offsets contained in the request for the creation of a new
 * annotation.
 */
private Offsets getOffsetsFromRequest(IRequestParameters request, JCas jCas, VID aVid) throws IOException {
    if (aVid.isNotSet() || aVid.isSynthetic()) {
        // Create new span annotation - in this case we get the offset information from the
        // request
        String offsets = request.getParameterValue(PARAM_OFFSETS).toString();
        OffsetsList offsetLists = JSONUtil.getJsonConverter().getObjectMapper().readValue(offsets, OffsetsList.class);
        int annotationBegin = getModelObject().getWindowBeginOffset() + offsetLists.get(0).getBegin();
        int annotationEnd = getModelObject().getWindowBeginOffset() + offsetLists.get(offsetLists.size() - 1).getEnd();
        return new Offsets(annotationBegin, annotationEnd);
    } else {
        // Edit existing span annotation - in this case we look up the offsets in the CAS
        // Let's not trust the client in this case.
        AnnotationFS fs = WebAnnoCasUtil.selectByAddr(jCas, aVid.getId());
        return new Offsets(fs.getBegin(), fs.getEnd());
    }
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) Offsets(de.tudarmstadt.ukp.clarin.webanno.brat.render.model.Offsets) OffsetsList(de.tudarmstadt.ukp.clarin.webanno.brat.render.model.OffsetsList)

Aggregations

Offsets (de.tudarmstadt.ukp.clarin.webanno.brat.render.model.Offsets)1 OffsetsList (de.tudarmstadt.ukp.clarin.webanno.brat.render.model.OffsetsList)1 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)1