use of de.tudarmstadt.ukp.clarin.webanno.brat.render.model.EntityType in project webanno by webanno.
the class BratRenderer method buildEntityTypes.
/**
* Generates brat type definitions from the WebAnno layer definitions.
*
* @param aAnnotationLayers
* the layers
* @param aAnnotationService
* the annotation service
* @return the brat type definitions
*/
public static Set<EntityType> buildEntityTypes(List<AnnotationLayer> aAnnotationLayers, AnnotationSchemaService aAnnotationService) {
// Sort layers
List<AnnotationLayer> layers = new ArrayList<>(aAnnotationLayers);
layers.sort(Comparator.comparing(AnnotationLayer::getName));
// Now build the actual configuration
Set<EntityType> entityTypes = new LinkedHashSet<>();
for (AnnotationLayer layer : layers) {
EntityType entityType = configureEntityType(layer);
List<RelationType> arcs = new ArrayList<>();
// For link features, we also need to configure the arcs, even though there is no arc
// layer here.
boolean hasLinkFeatures = false;
for (AnnotationFeature f : aAnnotationService.listAnnotationFeature(layer)) {
if (!LinkMode.NONE.equals(f.getLinkMode())) {
hasLinkFeatures = true;
break;
}
}
if (hasLinkFeatures) {
String bratTypeName = getBratTypeName(layer);
arcs.add(new RelationType(layer.getName(), layer.getUiName(), bratTypeName, bratTypeName, null, "triangle,5", "3,3"));
}
// Styles for the remaining relation and chain layers
for (AnnotationLayer attachingLayer : getAttachingLayers(layer, layers, aAnnotationService)) {
arcs.add(configureRelationType(layer, attachingLayer));
}
entityType.setArcs(arcs);
entityTypes.add(entityType);
}
return entityTypes;
}
Aggregations