/** * A field that takes the name of the annotation to attach to, e.g. * "de.tudarmstadt...type.Token" (Token.class.getName()) */ @Override public String getAttachTypeName() { return layer.getAttachType() == null ? null : layer.getAttachType().getName(); }
/** * A field that takes the name of the annotation to attach to, e.g. * "de.tudarmstadt...type.Token" (Token.class.getName()) */ @Override public String getAttachTypeName() { return getLayer().getAttachType() == null ? null : getLayer().getAttachType().getName(); } }
/** * A field that takes the name of the annotation to attach to, e.g. * "de.tudarmstadt...type.Token" (Token.class.getName()) */ @Override public String getAttachTypeName() { return getLayer().getAttachType() == null ? null : getLayer().getAttachType().getName(); } }
/** * Scan through the layers once to remember which layers attach to which layers. */ private static List<AnnotationLayer> getAttachingLayers(AnnotationLayer aTarget, List<AnnotationLayer> aLayers, AnnotationSchemaService aAnnotationService) { List<AnnotationLayer> attachingLayers = new ArrayList<>(); // Chains always attach to themselves if (CHAIN_TYPE.equals(aTarget.getType())) { attachingLayers.add(aTarget); } // FIXME This is a hack! Actually we should check the type of the attachFeature when // determine which layers attach to with other layers. Currently we only use attachType, // but do not follow attachFeature if it is set. if (aTarget.isBuiltIn() && aTarget.getName().equals(POS.class.getName())) { attachingLayers.add(aAnnotationService.getLayer(Dependency.class.getName(), aTarget.getProject())); } // Custom layers for (AnnotationLayer l : aLayers) { if (aTarget.equals(l.getAttachType())) { attachingLayers.add(l); } } return attachingLayers; }
/** * Scan through the layers once to remember which layers attach to which layers. */ private static List<AnnotationLayer> getAttachingLayers(AnnotationLayer aTarget, List<AnnotationLayer> aLayers, AnnotationSchemaService aAnnotationService) { List<AnnotationLayer> attachingLayers = new ArrayList<>(); // Chains always attach to themselves if (CHAIN_TYPE.equals(aTarget.getType())) { attachingLayers.add(aTarget); } // FIXME This is a hack! Actually we should check the type of the attachFeature when // determine which layers attach to with other layers. Currently we only use attachType, // but do not follow attachFeature if it is set. if (aTarget.isBuiltIn() && aTarget.getName().equals(POS.class.getName())) { attachingLayers.add(aAnnotationService.getLayer(Dependency.class.getName(), aTarget.getProject())); } // Custom layers for (AnnotationLayer l : aLayers) { if (aTarget.equals(l.getAttachType())) { attachingLayers.add(l); } } return attachingLayers; }
if (layer.getAttachType() != null) { layerToExLayers.get(layer).setAttachType( new ExportedAnnotationLayerReference(layer.getAttachType().getName()));
if (layer.getAttachType() != null) { layerToExLayers.get(layer).setAttachType( new ExportedAnnotationLayerReference(layer.getAttachType().getName()));
private IResourceStream exportLayerJson() { try { AnnotationLayer layer = getModelObject(); List<ExportedAnnotationLayer> exLayers = new ArrayList<>(); ExportedAnnotationLayer exMainLayer = ImportUtil.exportLayerDetails(null, null, layer, annotationService); exLayers.add(exMainLayer); // If the layer is attached to another layer, then we also have to export // that, otherwise we would be missing it during re-import. if (layer.getAttachType() != null) { AnnotationLayer attachLayer = layer.getAttachType(); ExportedAnnotationLayer exAttachLayer = ImportUtil.exportLayerDetails(null, null, attachLayer, annotationService); exMainLayer.setAttachType( new ExportedAnnotationLayerReference(exAttachLayer.getName())); exLayers.add(exAttachLayer); } return new InputStreamResourceStream(new ByteArrayInputStream( JSONUtil.toPrettyJsonString(exLayers).getBytes("UTF-8"))); } catch (Exception e) { error("Unable to generate the JSON file: " + ExceptionUtils.getRootCauseMessage(e)); ProjectLayersPanel.LOG.error("Unable to generate the JSON file", e); RequestCycle.get().find(IPartialPageRequestHandler.class) .ifPresent(handler -> handler.addChildren(getPage(), IFeedback.class)); return null; } }
private IResourceStream exportLayerJson() { try { AnnotationLayer layer = getModelObject(); List<ExportedAnnotationLayer> exLayers = new ArrayList<>(); ExportedAnnotationLayer exMainLayer = ImportUtil.exportLayerDetails(null, null, layer, annotationService); exLayers.add(exMainLayer); // If the layer is attached to another layer, then we also have to export // that, otherwise we would be missing it during re-import. if (layer.getAttachType() != null) { AnnotationLayer attachLayer = layer.getAttachType(); ExportedAnnotationLayer exAttachLayer = ImportUtil.exportLayerDetails(null, null, attachLayer, annotationService); exMainLayer.setAttachType( new ExportedAnnotationLayerReference(exAttachLayer.getName())); exLayers.add(exAttachLayer); } return new InputStreamResourceStream(new ByteArrayInputStream( JSONUtil.toPrettyJsonString(exLayers).getBytes("UTF-8"))); } catch (Exception e) { error("Unable to generate the JSON file: " + ExceptionUtils.getRootCauseMessage(e)); ProjectLayersPanel.LOG.error("Unable to generate the JSON file", e); RequestCycle.get().find(IPartialPageRequestHandler.class) .ifPresent(handler -> handler.addChildren(getPage(), IFeedback.class)); return null; } }
for (AnnotationLayer layer : annotationService.listAnnotationLayer(aBratAnnotatorModel .getProject())) { if (layer.getAttachType() != null && layer.getAttachType().equals(spanLayer)) { this.selectedLayer = layer; break;
private Set<AnnotationFS> getAttachedSpans(AnnotationFS aFs, AnnotationLayer aLayer) { CAS cas = aFs.getCAS(); Set<AnnotationFS> attachedSpans = new HashSet<>(); TypeAdapter adapter = annotationService.getAdapter(aLayer); if (adapter instanceof SpanAdapter && aLayer.getAttachType() != null) { Type spanType = CasUtil.getType(cas, aLayer.getAttachType().getName()); Feature attachFeature = spanType.getFeatureByBaseName(aLayer.getAttachFeature() .getName()); for (AnnotationFS attachedFs : selectAt(cas, spanType, aFs.getBegin(), aFs.getEnd())) { if (isSame(attachedFs.getFeatureValue(attachFeature), aFs)) { attachedSpans.add(attachedFs); } } } return attachedSpans; }
public static void addArcAnnotation(TypeAdapter aAdapter, JCas aJcas, int aAddressOriginClicked, int aAddressTargetClicked, String aFSArcaddress, JCas aClickedJCas, AnnotationFS aClickedFS) throws AnnotationException { AnnotationFS originFsClicked = selectByAddr(aClickedJCas, aAddressOriginClicked); AnnotationFS targetFsClicked = selectByAddr(aClickedJCas, aAddressTargetClicked); // this is a slot arc if (aFSArcaddress.contains(".")) { addSlotArcAnnotation((SpanAdapter) aAdapter, aJcas, aFSArcaddress, aClickedJCas, aClickedFS); } // normal relation annotation arc is clicked else { AnnotationLayer layer = aAdapter.getLayer(); addRelationArcAnnotation(aJcas, aClickedFS, layer.getAttachType() != null, layer.isAllowStacking(), originFsClicked, targetFsClicked); } }
public static void addArcAnnotation(TypeAdapter aAdapter, JCas aJcas, int aAddressOriginClicked, int aAddressTargetClicked, String aFSArcaddress, JCas aClickedJCas, AnnotationFS aClickedFS) throws AnnotationException { AnnotationFS originFsClicked = selectByAddr(aClickedJCas, aAddressOriginClicked); AnnotationFS targetFsClicked = selectByAddr(aClickedJCas, aAddressTargetClicked); // this is a slot arc if (aFSArcaddress.contains(".")) { addSlotArcAnnotation((SpanAdapter) aAdapter, aJcas, aFSArcaddress, aClickedJCas, aClickedFS); } // normal relation annotation arc is clicked else { AnnotationLayer layer = aAdapter.getLayer(); addRelationArcAnnotation(aJcas, aClickedFS, layer.getAttachType() != null, layer.isAllowStacking(), originFsClicked, targetFsClicked); } }
@Override public void generateTypes(TypeSystemDescription aTsd, AnnotationLayer aLayer) { TypeDescription td = aTsd.addType(aLayer.getName(), "", TYPE_NAME_ANNOTATION); AnnotationLayer attachType = aLayer.getAttachType(); td.addFeature(FEAT_REL_TARGET, "", attachType.getName()); td.addFeature(FEAT_REL_SOURCE, "", attachType.getName()); generateFeatures(aTsd, td, aLayer); }
@Override public void generateTypes(TypeSystemDescription aTsd, AnnotationLayer aLayer) { TypeDescription td = aTsd.addType(aLayer.getName(), "", TYPE_NAME_ANNOTATION); AnnotationLayer attachType = aLayer.getAttachType(); td.addFeature(FEAT_REL_TARGET, "", attachType.getName()); td.addFeature(FEAT_REL_SOURCE, "", attachType.getName()); generateFeatures(aTsd, td, aLayer); }
if (layer.getAttachType() != null) { AnnotationLayer attachLayer = layer.getAttachType(); de.tudarmstadt.ukp.clarin.webanno.model.export.AnnotationLayer exAttachLayer = ProjectUtil .exportLayerDetails(null, null, attachLayer, annotationService);
getType(aCas, layer.getAttachType().getName()))) { AnnotationFS anno = getFeature(attach, layer.getAttachFeature().getName(), AnnotationFS.class);
@Override public CreateRelationAnnotationRequest onCreate(RelationAdapter aAdapter, CreateRelationAnnotationRequest aRequest) { if (aAdapter.getLayer().getAttachFeature() == null) { return aRequest; } // FIXME The code below appears to be broken - it basically only works because the only // case were we use the attach-feature is with the Dependency/Token layers and it works // because tokens cannot stack. "selectCovered" below would need to be replaced with // an actual lookup of the annotation pointed to by the attach-feature. final CAS cas = aRequest.getJcas().getCas(); final Type attachType = getType(cas, aAdapter.getLayer().getAttachType().getName()); AnnotationFS originFS = aRequest.getOriginFs(); AnnotationFS targetFS = aRequest.getTargetFs(); targetFS = selectCovered(cas, attachType, targetFS.getBegin(), targetFS.getEnd()).get(0); originFS = selectCovered(cas, attachType, originFS.getBegin(), originFS.getEnd()).get(0); return aRequest.changeRelation(originFS, targetFS); }
@Override public CreateRelationAnnotationRequest onCreate(RelationAdapter aAdapter, CreateRelationAnnotationRequest aRequest) { if (aAdapter.getLayer().getAttachFeature() == null) { return aRequest; } // FIXME The code below appears to be broken - it basically only works because the only // case were we use the attach-feature is with the Dependency/Token layers and it works // because tokens cannot stack. "selectCovered" below would need to be replaced with // an actual lookup of the annotation pointed to by the attach-feature. final CAS cas = aRequest.getJcas().getCas(); final Type attachType = getType(cas, aAdapter.getLayer().getAttachType().getName()); AnnotationFS originFS = aRequest.getOriginFs(); AnnotationFS targetFS = aRequest.getTargetFs(); targetFS = selectCovered(cas, attachType, targetFS.getBegin(), targetFS.getEnd()).get(0); originFS = selectCovered(cas, attachType, originFS.getBegin(), originFS.getEnd()).get(0); return aRequest.changeRelation(originFS, targetFS); }
ArcAdapter adapter = new ArcAdapter(aLayer, aLayer.getId(), aLayer.getName(), "Dependent", "Governor", aLayer.getAttachFeature() == null ? null : aLayer .getAttachFeature().getName(), aLayer.getAttachType().getName());