use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter_ImplBase in project webanno by webanno.
the class CasDiff method getDiffAdapters.
public static List<DiffAdapter> getDiffAdapters(AnnotationSchemaService schemaService, Iterable<AnnotationLayer> aLayers) {
List<DiffAdapter> adapters = new ArrayList<>();
nextLayer: for (AnnotationLayer layer : aLayers) {
if (!layer.isEnabled()) {
continue nextLayer;
}
Set<String> labelFeatures = new LinkedHashSet<>();
nextFeature: for (AnnotationFeature f : schemaService.listSupportedFeatures(layer)) {
if (!f.isEnabled()) {
continue nextFeature;
}
// Link features are treated separately from primitive label features
if (!NONE.equals(f.getLinkMode())) {
continue nextFeature;
}
labelFeatures.add(f.getName());
}
DiffAdapter_ImplBase adapter;
switch(layer.getType()) {
case SPAN_TYPE:
{
adapter = new SpanDiffAdapter(layer.getName(), labelFeatures);
break;
}
case RELATION_TYPE:
{
RelationAdapter typeAdpt = (RelationAdapter) schemaService.getAdapter(layer);
adapter = new RelationDiffAdapter(layer.getName(), typeAdpt.getSourceFeatureName(), typeAdpt.getTargetFeatureName(), labelFeatures);
break;
}
default:
LOG.debug("Curation for layer type [{}] not supported - ignoring", layer.getType());
continue nextLayer;
}
adapters.add(adapter);
nextFeature: for (AnnotationFeature f : schemaService.listSupportedFeatures(layer)) {
if (!f.isEnabled()) {
continue nextFeature;
}
switch(f.getLinkMode()) {
case NONE:
// Nothing to do here
break;
case SIMPLE:
adapter.addLinkFeature(f.getName(), f.getLinkTypeRoleFeatureName(), null);
break;
case WITH_ROLE:
adapter.addLinkFeature(f.getName(), f.getLinkTypeRoleFeatureName(), f.getLinkTypeTargetFeatureName());
break;
default:
throw new IllegalStateException("Unknown link mode [" + f.getLinkMode() + "]");
}
labelFeatures.add(f.getName());
}
}
return adapters;
}
Aggregations