public CreateRelationAnnotationRequest changeRelation(AnnotationFS aOrigin, AnnotationFS aTarget) { return new CreateRelationAnnotationRequest(this, document, username, jcas, aOrigin, aTarget, windowBegin, windowEnd); } }
public AnnotationFS handle(CreateRelationAnnotationRequest aRequest) throws AnnotationException { CreateRelationAnnotationRequest request = aRequest; for (RelationLayerBehavior behavior : behaviors) { request = behavior.onCreate(this, request); } return createRelationAnnotation(request.getJcas().getCas(), request.getOriginFs(), request.getTargetFs()); }
final JCas jcas = aRequest.getJcas(); final Type type = getType(jcas.getCas(), aAdapter.getLayer().getName()); final Feature dependentFeature = type.getFeatureByBaseName(aAdapter.getTargetFeatureName()); for (AnnotationFS fs : selectCovered(jcas.getCas(), type, aRequest.getWindowBegin(), aRequest.getWindowEnd())) { AnnotationFS existingTargetFS = (AnnotationFS) fs.getFeatureValue(dependentFeature); AnnotationFS existingOriginFS = (AnnotationFS) fs.getFeatureValue(governorFeature); if (isDuplicate(existingOriginFS, aRequest.getOriginFs(), existingTargetFS, aRequest.getTargetFs())) { throw new AnnotationException("Cannot create another annotation of layer [" + layer.getUiName() + "] at this location - stacking is not "
@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); }
final JCas jcas = aRequest.getJcas(); final Type type = getType(jcas.getCas(), aAdapter.getLayer().getName()); final Feature dependentFeature = type.getFeatureByBaseName(aAdapter.getTargetFeatureName()); for (AnnotationFS fs : selectCovered(jcas.getCas(), type, aRequest.getWindowBegin(), aRequest.getWindowEnd())) { AnnotationFS existingTargetFS = (AnnotationFS) fs.getFeatureValue(dependentFeature); AnnotationFS existingOriginFS = (AnnotationFS) fs.getFeatureValue(governorFeature); if (isDuplicate(existingOriginFS, aRequest.getOriginFs(), existingTargetFS, aRequest.getTargetFs())) { throw new AnnotationException("Cannot create another annotation of layer [" + layer.getUiName() + "] at this location - stacking is not "
@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); }
public AnnotationFS handle(CreateRelationAnnotationRequest aRequest) throws AnnotationException { CreateRelationAnnotationRequest request = aRequest; for (RelationLayerBehavior behavior : behaviors) { request = behavior.onCreate(this, request); } return createRelationAnnotation(request.getJcas().getCas(), request.getOriginFs(), request.getTargetFs()); }
public CreateRelationAnnotationRequest changeRelation(AnnotationFS aOrigin, AnnotationFS aTarget) { return new CreateRelationAnnotationRequest(this, document, username, jcas, aOrigin, aTarget, windowBegin, windowEnd); } }
@Override public CreateRelationAnnotationRequest onCreate(RelationAdapter aAdapter, CreateRelationAnnotationRequest aRequest) throws AnnotationException { if (aAdapter.getLayer().isCrossSentence()) { return aRequest; } if (!isBeginEndInSameSentence(aRequest.getJcas(), aRequest.getOriginFs().getBegin(), aRequest.getTargetFs().getEnd())) { throw new MultipleSentenceCoveredException("Annotation coveres multiple sentences, " + "limit your annotation to single sentence!"); } return aRequest; }
/** * Update the CAS with new/modification of arc annotations from brat * * @param aDocument * the document to which the CAS belongs * @param aUsername * the user to which the CAS belongs * @param aOriginFs * the origin FS. * @param aTargetFs * the target FS. * @param aJCas * the JCas. * @param aWindowBegin * begin offset of the first visible sentence * @param aWindowEnd * end offset of the last visible sentence * @return the ID. * @throws AnnotationException * if the annotation could not be created/updated. */ public AnnotationFS add(SourceDocument aDocument, String aUsername, AnnotationFS aOriginFs, AnnotationFS aTargetFs, JCas aJCas, int aWindowBegin, int aWindowEnd) throws AnnotationException { return handle(new CreateRelationAnnotationRequest(aDocument, aUsername, aJCas, aOriginFs, aTargetFs, aWindowBegin, aWindowEnd)); }
@Override public CreateRelationAnnotationRequest onCreate(RelationAdapter aAdapter, CreateRelationAnnotationRequest aRequest) throws AnnotationException { if (aAdapter.getLayer().isCrossSentence()) { return aRequest; } if (!isBeginEndInSameSentence(aRequest.getJcas(), aRequest.getOriginFs().getBegin(), aRequest.getTargetFs().getEnd())) { throw new MultipleSentenceCoveredException("Annotation coveres multiple sentences, " + "limit your annotation to single sentence!"); } return aRequest; }
/** * Update the CAS with new/modification of arc annotations from brat * * @param aDocument * the document to which the CAS belongs * @param aUsername * the user to which the CAS belongs * @param aOriginFs * the origin FS. * @param aTargetFs * the target FS. * @param aJCas * the JCas. * @param aWindowBegin * begin offset of the first visible sentence * @param aWindowEnd * end offset of the last visible sentence * @return the ID. * @throws AnnotationException * if the annotation could not be created/updated. */ public AnnotationFS add(SourceDocument aDocument, String aUsername, AnnotationFS aOriginFs, AnnotationFS aTargetFs, JCas aJCas, int aWindowBegin, int aWindowEnd) throws AnnotationException { return handle(new CreateRelationAnnotationRequest(aDocument, aUsername, aJCas, aOriginFs, aTargetFs, aWindowBegin, aWindowEnd)); }