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);
}
}
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());
}
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);
}
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);
}
Aggregations