Search in sources :

Example 1 with ExportedAnnotationFeatureReference

use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference in project webanno by webanno.

the class AutomationMiraTemplateExporter method importData.

@Override
public void importData(ProjectImportRequest aRequest, Project aProject, ExportedProject aExProject, ZipFile aZip) throws Exception {
    ExportedMiraTemplate[] templates = aExProject.getArrayProperty(MIRA_TEMPLATES, ExportedMiraTemplate.class);
    for (ExportedMiraTemplate exTemplate : templates) {
        MiraTemplate template = new MiraTemplate();
        template.setAnnotateAndRepeat(exTemplate.isAnnotateAndPredict());
        template.setAutomationStarted(false);
        template.setCurrentLayer(exTemplate.isCurrentLayer());
        template.setResult("---");
        AnnotationLayer trainingLayer = annotationService.findLayer(aProject, exTemplate.getTrainFeature().getLayer());
        AnnotationFeature trainingFeature = annotationService.getFeature(exTemplate.getTrainFeature().getName(), trainingLayer);
        template.setTrainFeature(trainingFeature);
        Set<AnnotationFeature> otherFeatures = new HashSet<>();
        if (exTemplate.getOtherFeatures() != null) {
            for (ExportedAnnotationFeatureReference other : exTemplate.getOtherFeatures()) {
                AnnotationLayer layer = annotationService.findLayer(aProject, other.getLayer());
                AnnotationFeature feature = annotationService.getFeature(other.getName(), layer);
                otherFeatures.add(feature);
            }
            template.setOtherFeatures(otherFeatures);
        }
        automationService.createTemplate(template);
    }
}
Also used : ExportedMiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate) ExportedMiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate) MiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.model.MiraTemplate) ExportedAnnotationFeatureReference(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) HashSet(java.util.HashSet)

Example 2 with ExportedAnnotationFeatureReference

use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference in project webanno by webanno.

the class LayerExporter method exportData.

@Override
public void exportData(ProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor, ExportedProject aExProject, File aStage) throws Exception {
    List<ExportedAnnotationLayer> exLayers = new ArrayList<>();
    // Store map of layer and its equivalent exLayer so that the attach type is attached later
    Map<AnnotationLayer, ExportedAnnotationLayer> layerToExLayers = new HashMap<>();
    // Store map of feature and its equivalent exFeature so that the attach feature is attached
    // later
    Map<AnnotationFeature, ExportedAnnotationFeature> featureToExFeatures = new HashMap<>();
    for (AnnotationLayer layer : annotationService.listAnnotationLayer(aRequest.getProject())) {
        exLayers.add(exportLayerDetails(layerToExLayers, featureToExFeatures, layer));
    }
    // add the attach-type and attach-feature to the exported layers and exported feature
    for (AnnotationLayer layer : layerToExLayers.keySet()) {
        if (layer.getAttachType() != null) {
            layerToExLayers.get(layer).setAttachType(new ExportedAnnotationLayerReference(layer.getAttachType().getName()));
        }
        if (layer.getAttachFeature() != null) {
            layerToExLayers.get(layer).setAttachFeature(new ExportedAnnotationFeatureReference(layer.getAttachFeature()));
        }
    }
    aExProject.setLayers(exLayers);
    LOG.info("Exported [{}] layers for project [{}]", exLayers.size(), aRequest.getProject().getName());
}
Also used : ExportedAnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer) HashMap(java.util.HashMap) ExportedAnnotationLayerReference(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayerReference) ArrayList(java.util.ArrayList) ExportedAnnotationFeatureReference(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) ExportedAnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 3 with ExportedAnnotationFeatureReference

use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference in project webanno by webanno.

the class AutomationMiraTemplateExporter method exportData.

@Override
public void exportData(ProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor, ExportedProject aExProject, File aStage) throws Exception {
    List<ExportedMiraTemplate> exTemplates = new ArrayList<>();
    for (MiraTemplate template : automationService.listMiraTemplates(aRequest.getProject())) {
        ExportedMiraTemplate exTemplate = new ExportedMiraTemplate();
        exTemplate.setAnnotateAndPredict(template.isAnnotateAndRepeat());
        exTemplate.setAutomationStarted(template.isAutomationStarted());
        exTemplate.setCurrentLayer(template.isCurrentLayer());
        exTemplate.setResult(template.getResult());
        exTemplate.setTrainFeature(new ExportedAnnotationFeatureReference(template.getTrainFeature()));
        if (template.getOtherFeatures().size() > 0) {
            Set<ExportedAnnotationFeatureReference> exOtherFeatures = new HashSet<>();
            for (AnnotationFeature feature : template.getOtherFeatures()) {
                exOtherFeatures.add(new ExportedAnnotationFeatureReference(feature));
            }
            exTemplate.setOtherFeatures(exOtherFeatures);
        }
        exTemplates.add(exTemplate);
    }
    aExProject.setProperty(MIRA_TEMPLATES, exTemplates);
}
Also used : ExportedMiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate) ExportedMiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate) MiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.model.MiraTemplate) ArrayList(java.util.ArrayList) ExportedAnnotationFeatureReference(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference) HashSet(java.util.HashSet) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 4 with ExportedAnnotationFeatureReference

use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference in project webanno by webanno.

the class AutomationTrainingDocumentExporter method exportTrainingDocuments.

private void exportTrainingDocuments(Project aProject, ExportedProject aExProject) {
    List<ExportedTrainingDocument> trainDocuments = new ArrayList<>();
    List<TrainingDocument> trainingDocuments = automationService.listTrainingDocuments(aProject);
    for (TrainingDocument trainingDocument : trainingDocuments) {
        ExportedTrainingDocument exDocument = new ExportedTrainingDocument();
        exDocument.setFormat(trainingDocument.getFormat());
        exDocument.setName(trainingDocument.getName());
        exDocument.setState(trainingDocument.getState());
        exDocument.setTimestamp(trainingDocument.getTimestamp());
        exDocument.setSentenceAccessed(trainingDocument.getSentenceAccessed());
        // actual AnnotationFeature in the project
        if (trainingDocument.getFeature() != null) {
            exDocument.setFeature(new ExportedAnnotationFeatureReference(trainingDocument.getFeature()));
        }
        trainDocuments.add(exDocument);
    }
    aExProject.setProperty(TRAINING_DOCUMENTS, trainDocuments);
}
Also used : ExportedTrainingDocument(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedTrainingDocument) ArrayList(java.util.ArrayList) ExportedAnnotationFeatureReference(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference) ExportedTrainingDocument(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedTrainingDocument) TrainingDocument(de.tudarmstadt.ukp.clarin.webanno.model.TrainingDocument)

Aggregations

ExportedAnnotationFeatureReference (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference)4 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)3 ArrayList (java.util.ArrayList)3 MiraTemplate (de.tudarmstadt.ukp.clarin.webanno.automation.model.MiraTemplate)2 ExportedMiraTemplate (de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate)2 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)2 HashSet (java.util.HashSet)2 ExportedTrainingDocument (de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedTrainingDocument)1 ExportedAnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature)1 ExportedAnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer)1 ExportedAnnotationLayerReference (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayerReference)1 TrainingDocument (de.tudarmstadt.ukp.clarin.webanno.model.TrainingDocument)1 HashMap (java.util.HashMap)1