Search in sources :

Example 1 with StopWatch

use of de.tudarmstadt.ukp.clarin.webanno.support.StopWatch in project webanno by webanno.

the class SuggestionBuilder method createCurationCas.

/**
 * For the first time a curation page is opened, create a MergeCas that contains only agreeing
 * annotations Using the CAS of the curator user.
 *
 * @param aState
 *            the annotator state
 * @param aRandomAnnotationDocument
 *            an annotation document.
 * @param aCasses
 *            the CASes
 * @param aAnnotationLayers
 *            the layers.
 * @return the CAS.
 * @throws IOException
 *             if an I/O error occurs.
 */
private CAS createCurationCas(AnnotatorState aState, AnnotationDocument aRandomAnnotationDocument, Map<String, CAS> aCasses, List<AnnotationLayer> aAnnotationLayers, boolean aMergeIncompleteAnnotations) throws IOException, UIMAException, AnnotationException {
    Validate.notNull(aState, "State must be specified");
    Validate.notNull(aRandomAnnotationDocument, "Annotation document must be specified");
    // We need a modifiable copy of some annotation document which we can use to initialize
    // the curation CAS. This is an exceptional case where BYPASS is the correct choice
    CAS mergeCas = documentService.readAnnotationCas(aRandomAnnotationDocument, UNMANAGED_ACCESS);
    List<DiffAdapter> adapters = getDiffAdapters(schemaService, aState.getAnnotationLayers());
    DiffResult diff;
    try (StopWatch watch = new StopWatch(log, "CasDiff")) {
        diff = doDiffSingle(adapters, LINK_ROLE_AS_LABEL, aCasses, 0, mergeCas.getDocumentText().length()).toResult();
    }
    try (StopWatch watch = new StopWatch(log, "CasMerge")) {
        CasMerge casMerge = new CasMerge(schemaService);
        casMerge.setMergeIncompleteAnnotations(aMergeIncompleteAnnotations);
        casMerge.reMergeCas(diff, aState.getDocument(), aState.getUser().getUsername(), mergeCas, aCasses);
    }
    curationDocumentService.writeCurationCas(mergeCas, aRandomAnnotationDocument.getDocument(), false);
    return mergeCas;
}
Also used : CAS(org.apache.uima.cas.CAS) CasMerge(de.tudarmstadt.ukp.clarin.webanno.curation.casmerge.CasMerge) DiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) StopWatch(de.tudarmstadt.ukp.clarin.webanno.support.StopWatch)

Aggregations

DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult)1 DiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter)1 CasMerge (de.tudarmstadt.ukp.clarin.webanno.curation.casmerge.CasMerge)1 StopWatch (de.tudarmstadt.ukp.clarin.webanno.support.StopWatch)1 CAS (org.apache.uima.cas.CAS)1