Search in sources :

Example 1 with ExportedTrainingDocument

use of de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedTrainingDocument 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)

Example 2 with ExportedTrainingDocument

use of de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedTrainingDocument in project webanno by webanno.

the class AutomationTrainingDocumentExporter method importTrainingDocuments.

private void importTrainingDocuments(ExportedProject aExProject, Project aProject) throws IOException {
    ExportedTrainingDocument[] trainingDocuments = aExProject.getArrayProperty(TRAINING_DOCUMENTS, ExportedTrainingDocument.class);
    for (ExportedTrainingDocument importedTrainingDocument : trainingDocuments) {
        TrainingDocument trainingDocument = new TrainingDocument();
        trainingDocument.setFormat(importedTrainingDocument.getFormat());
        trainingDocument.setName(importedTrainingDocument.getName());
        trainingDocument.setState(importedTrainingDocument.getState());
        trainingDocument.setProject(aProject);
        trainingDocument.setTimestamp(importedTrainingDocument.getTimestamp());
        trainingDocument.setSentenceAccessed(importedTrainingDocument.getSentenceAccessed());
        if (importedTrainingDocument.getFeature() != null) {
            AnnotationLayer trainingLayer = annotationService.findLayer(aProject, importedTrainingDocument.getFeature().getLayer());
            AnnotationFeature trainingFeature = annotationService.getFeature(importedTrainingDocument.getFeature().getName(), trainingLayer);
            trainingDocument.setFeature(trainingFeature);
        }
        automationService.createTrainingDocument(trainingDocument);
    }
}
Also used : ExportedTrainingDocument(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedTrainingDocument) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) ExportedTrainingDocument(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedTrainingDocument) TrainingDocument(de.tudarmstadt.ukp.clarin.webanno.model.TrainingDocument) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Aggregations

ExportedTrainingDocument (de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedTrainingDocument)2 TrainingDocument (de.tudarmstadt.ukp.clarin.webanno.model.TrainingDocument)2 ExportedAnnotationFeatureReference (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference)1 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)1 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1 ArrayList (java.util.ArrayList)1