Search in sources :

Example 1 with RouteToAnalyzeEvent

use of de.catma.ui.events.routing.RouteToAnalyzeEvent in project catma by forTEXT.

the class TaggerView method analyzeDocument.

public void analyzeDocument() {
    Corpus corpus = new Corpus();
    corpus.addSourceDocument(sourceDocument);
    for (AnnotationCollection umc : userMarkupCollectionManager.getUserMarkupCollections()) {
        AnnotationCollectionReference userMarkupCollRef = sourceDocument.getUserMarkupCollectionReference(umc.getId());
        if (userMarkupCollRef != null) {
            corpus.addUserMarkupCollectionReference(userMarkupCollRef);
        }
    }
    if (project instanceof IndexedProject) {
        eventBus.post(new RouteToAnalyzeEvent((IndexedProject) project, corpus));
    }
}
Also used : AnnotationCollection(de.catma.document.annotation.AnnotationCollection) AnnotationCollectionReference(de.catma.document.annotation.AnnotationCollectionReference) IndexedProject(de.catma.indexer.IndexedProject) Corpus(de.catma.document.corpus.Corpus) RouteToAnalyzeEvent(de.catma.ui.events.routing.RouteToAnalyzeEvent)

Example 2 with RouteToAnalyzeEvent

use of de.catma.ui.events.routing.RouteToAnalyzeEvent in project catma by forTEXT.

the class ProjectView method handleAnalyzeResources.

private void handleAnalyzeResources(MenuBar.MenuItem menuItem, TreeGrid<Resource> resourceGrid) {
    if (resourceGrid.getSelectedItems().isEmpty()) {
        Notification.show("Info", "Please select something first!", Type.HUMANIZED_MESSAGE);
    } else {
        Corpus corpus = new Corpus();
        for (Resource resource : resourceGrid.getSelectedItems()) {
            try {
                if (resource.getClass().equals(DocumentResource.class)) {
                    DocumentResource docResource = (DocumentResource) resource;
                    corpus.addSourceDocument(docResource.getDocument());
                } else {
                    CollectionResource collResource = (CollectionResource) resource;
                    corpus.addUserMarkupCollectionReference(collResource.getCollectionReference());
                    DocumentResource docParent = (DocumentResource) resourceGrid.getTreeData().getParent(collResource);
                    if (!corpus.getSourceDocuments().contains(docParent.getDocument())) {
                        corpus.addSourceDocument(docParent.getDocument());
                    }
                }
            } catch (Exception e) {
                errorHandler.showAndLogError("Error adding resource to analyzer module " + resource, e);
            }
        }
        eventBus.post(new RouteToAnalyzeEvent((IndexedProject) project, corpus));
    }
}
Also used : IndexedProject(de.catma.indexer.IndexedProject) Corpus(de.catma.document.corpus.Corpus) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) RouteToAnalyzeEvent(de.catma.ui.events.routing.RouteToAnalyzeEvent)

Aggregations

Corpus (de.catma.document.corpus.Corpus)2 IndexedProject (de.catma.indexer.IndexedProject)2 RouteToAnalyzeEvent (de.catma.ui.events.routing.RouteToAnalyzeEvent)2 AnnotationCollection (de.catma.document.annotation.AnnotationCollection)1 AnnotationCollectionReference (de.catma.document.annotation.AnnotationCollectionReference)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1