Search in sources :

Example 6 with SuggestionBuilder

use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder in project webanno by webanno.

the class CurationPage method actionLoadDocument.

/**
 * Open a document or to a different document. This method should be used only the first time
 * that a document is accessed. It reset the annotator state and upgrades the CAS.
 */
@Override
protected void actionLoadDocument(AjaxRequestTarget aTarget) {
    LOG.info("BEGIN LOAD_DOCUMENT_ACTION");
    AnnotatorState state = getModelObject();
    String username = SecurityContextHolder.getContext().getAuthentication().getName();
    User user = userRepository.get(username);
    state.setUser(user);
    try {
        // ANNOTATION_FINISHED
        if (!SourceDocumentState.CURATION_FINISHED.equals(state.getDocument().getState())) {
            documentService.transitionSourceDocumentState(state.getDocument(), ANNOTATION_IN_PROGRESS_TO_CURATION_IN_PROGRESS);
        }
        // Load user preferences
        PreferencesUtil.loadPreferences(username, settingsService, projectService, annotationService, state, state.getMode());
        // Re-render whole page as sidebar size preference may have changed
        aTarget.add(CurationPage.this);
        List<AnnotationDocument> finishedAnnotationDocuments = new ArrayList<>();
        for (AnnotationDocument annotationDocument : documentService.listAnnotationDocuments(state.getDocument())) {
            if (annotationDocument.getState().equals(AnnotationDocumentState.FINISHED)) {
                finishedAnnotationDocuments.add(annotationDocument);
            }
        }
        SuggestionBuilder cb = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
        AnnotationDocument randomAnnotationDocument = null;
        if (finishedAnnotationDocuments.size() > 0) {
            randomAnnotationDocument = finishedAnnotationDocuments.get(0);
        }
        // annotation
        for (AnnotationDocument ad : finishedAnnotationDocuments) {
            upgradeCasAndSave(ad.getDocument(), ad.getUser());
        }
        Map<String, JCas> jCases = cb.listJcasesforCuration(finishedAnnotationDocuments, randomAnnotationDocument, state.getMode());
        JCas mergeJCas = cb.getMergeCas(state, state.getDocument(), jCases, randomAnnotationDocument, true);
        // (Re)initialize brat model after potential creating / upgrading CAS
        state.reset();
        state.getPreferences().setCurationWindowSize(WebAnnoCasUtil.getSentenceCount(mergeJCas));
        // Initialize the visible content
        state.setFirstVisibleUnit(WebAnnoCasUtil.getFirstSentence(mergeJCas));
        // if project is changed, reset some project specific settings
        if (currentprojectId != state.getProject().getId()) {
            state.clearRememberedFeatures();
        }
        currentprojectId = state.getProject().getId();
        SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
        curationContainer = builder.buildCurationContainer(state);
        curationContainer.setBratAnnotatorModel(state);
        curationPanel.editor.reset(aTarget);
        updatePanel(curationContainer, aTarget);
        updateSentenceNumber(mergeJCas, state.getFirstVisibleUnitAddress());
        curationPanel.init(aTarget, curationContainer);
        // curationPanel.updatePanel(aTarget, curationContainer);
        // Load constraints
        state.setConstraints(constraintsService.loadConstraints(state.getProject()));
        aTarget.add(getOrCreatePositionInfoLabel());
        aTarget.add(documentNamePanel);
        aTarget.add(remergeDocumentLink);
        aTarget.add(finishDocumentLink);
    } catch (Exception e) {
        handleException(aTarget, e);
    }
    LOG.info("END LOAD_DOCUMENT_ACTION");
}
Also used : User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) ArrayList(java.util.ArrayList) JCas(org.apache.uima.jcas.JCas) AnnotationDocument(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument) SuggestionBuilder(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) UIMAException(org.apache.uima.UIMAException) IOException(java.io.IOException)

Example 7 with SuggestionBuilder

use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder in project webanno by webanno.

the class CorrectionPage method actionRefreshDocument.

@Override
protected void actionRefreshDocument(AjaxRequestTarget aTarget) {
    try {
        AnnotatorState state = getModelObject();
        SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
        curationContainer = builder.buildCurationContainer(state);
        setCurationSegmentBeginEnd(getEditorCas());
        curationContainer.setBratAnnotatorModel(state);
        update(aTarget);
        annotationEditor.requestRender(aTarget);
    } catch (Exception e) {
        handleException(aTarget, e);
    }
}
Also used : AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) SuggestionBuilder(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) UIMAException(org.apache.uima.UIMAException) IOException(java.io.IOException)

Example 8 with SuggestionBuilder

use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder in project webanno by webanno.

the class CorrectionPage method createDetailEditor.

private AnnotationDetailEditorPanel createDetailEditor() {
    return new AnnotationDetailEditorPanel("annotationDetailEditorPanel", getModel()) {

        private static final long serialVersionUID = 2857345299480098279L;

        @Override
        protected void onChange(AjaxRequestTarget aTarget) {
            aTarget.addChildren(getPage(), IFeedback.class);
            aTarget.add(getOrCreatePositionInfoLabel());
            try {
                AnnotatorState state = getModelObject();
                JCas editorCas = getEditorCas();
                // JCas correctionCas = repository.readCorrectionCas(state.getDocument());
                annotationEditor.requestRender(aTarget);
                // info(bratAnnotatorModel.getMessage());
                SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
                curationContainer = builder.buildCurationContainer(state);
                setCurationSegmentBeginEnd(editorCas);
                curationContainer.setBratAnnotatorModel(state);
                update(aTarget);
            } catch (Exception e) {
                handleException(this, aTarget, e);
            }
        }

        @Override
        protected void onAutoForward(AjaxRequestTarget aTarget) {
            annotationEditor.requestRender(aTarget);
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) JCas(org.apache.uima.jcas.JCas) SuggestionBuilder(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder) AnnotationDetailEditorPanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) UIMAException(org.apache.uima.UIMAException) IOException(java.io.IOException)

Example 9 with SuggestionBuilder

use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder in project webanno by webanno.

the class CorrectionPage method actionGotoPage.

private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception {
    AnnotatorState state = getModelObject();
    JCas editorCas = getEditorCas();
    List<Sentence> sentences = new ArrayList<>(select(editorCas, Sentence.class));
    int selectedSentence = gotoPageTextField.getModelObject();
    selectedSentence = Math.min(selectedSentence, sentences.size());
    gotoPageTextField.setModelObject(selectedSentence);
    state.setFirstVisibleUnit(sentences.get(selectedSentence - 1));
    state.setFocusUnitIndex(selectedSentence);
    SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository);
    curationContainer = builder.buildCurationContainer(state);
    setCurationSegmentBeginEnd(editorCas);
    curationContainer.setBratAnnotatorModel(state);
    update(aTarget);
    aTarget.add(gotoPageTextField);
    annotationEditor.requestRender(aTarget);
}
Also used : AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) ArrayList(java.util.ArrayList) JCas(org.apache.uima.jcas.JCas) Sentence(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence) SuggestionBuilder(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder)

Aggregations

AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)9 SuggestionBuilder (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SuggestionBuilder)9 AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)7 IOException (java.io.IOException)7 UIMAException (org.apache.uima.UIMAException)7 JCas (org.apache.uima.jcas.JCas)7 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)4 ArrayList (java.util.ArrayList)3 AnnotationDetailEditorPanel (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 ProjectType (de.tudarmstadt.ukp.clarin.webanno.api.ProjectType)1 AnnotationDocument (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument)1 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)1 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1 Tag (de.tudarmstadt.ukp.clarin.webanno.model.Tag)1 TagSet (de.tudarmstadt.ukp.clarin.webanno.model.TagSet)1 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)1 Feature (org.apache.uima.cas.Feature)1 Type (org.apache.uima.cas.Type)1 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)1