private AnnotationFS createChainElementAnnotation(CreateSpanAnnotationRequest aRequest) { // Add the link annotation on the span AnnotationFS newLink = newLink(aRequest.getJcas(), aRequest.getBegin(), aRequest.getEnd()); // The added link is a new chain on its own - add the chain head FS newChain(aRequest.getJcas(), newLink); return newLink; }
private AnnotationFS createChainElementAnnotation(CreateSpanAnnotationRequest aRequest) { // Add the link annotation on the span AnnotationFS newLink = newLink(aRequest.getJcas(), aRequest.getBegin(), aRequest.getEnd()); // The added link is a new chain on its own - add the chain head FS newChain(aRequest.getJcas(), newLink); return newLink; }
@Override public CreateSpanAnnotationRequest onCreate(TypeAdapter aAdapter, CreateSpanAnnotationRequest aRequest) throws AnnotationException { if (aAdapter.getLayer().isCrossSentence()) { return aRequest; } if (!isBeginEndInSameSentence(aRequest.getJcas(), aRequest.getBegin(), aRequest.getEnd())) { throw new MultipleSentenceCoveredException("Annotation covers multiple sentences, " + "limit your annotation to single sentence!"); } return aRequest; }
@Override public CreateSpanAnnotationRequest onCreate(TypeAdapter aAdapter, CreateSpanAnnotationRequest aRequest) throws AnnotationException { if (aAdapter.getLayer().isCrossSentence()) { return aRequest; } if (!isBeginEndInSameSentence(aRequest.getJcas(), aRequest.getBegin(), aRequest.getEnd())) { throw new MultipleSentenceCoveredException("Annotation covers multiple sentences, " + "limit your annotation to single sentence!"); } return aRequest; }
public AnnotationFS handle(CreateSpanAnnotationRequest aRequest) throws AnnotationException { CreateSpanAnnotationRequest request = aRequest; for (SpanLayerBehavior behavior : behaviors) { request = behavior.onCreate(this, request); } AnnotationFS newAnnotation = createSpanAnnotation(request.getJcas().getCas(), request.getBegin(), request.getEnd()); publishEvent(new SpanCreatedEvent(this, request.getDocument(), request.getUsername(), newAnnotation)); return newAnnotation; }
public AnnotationFS handle(CreateSpanAnnotationRequest aRequest) throws AnnotationException { CreateSpanAnnotationRequest request = aRequest; for (SpanLayerBehavior behavior : behaviors) { request = behavior.onCreate(this, request); } AnnotationFS newAnnotation = createSpanAnnotation(request.getJcas().getCas(), request.getBegin(), request.getEnd()); publishEvent(new SpanCreatedEvent(this, request.getDocument(), request.getUsername(), newAnnotation)); return newAnnotation; }
@Override public CreateSpanAnnotationRequest onCreate(TypeAdapter aAdapter, CreateSpanAnnotationRequest aRequest) throws AnnotationException { if (aRequest.getBegin() == aRequest.getEnd()) { if (!aAdapter.getLayer().getAnchoringMode().isZeroSpanAllowed()) { throw new AnnotationException( "Cannot create zero-width annotation on layers that lock to token boundaries."); } return aRequest; } int[] originalRange = new int[] { aRequest.getBegin(), aRequest.getEnd() }; int[] adjustedRange = adjust(aRequest.getJcas(), aAdapter.getLayer().getAnchoringMode(), originalRange); if (adjustedRange.equals(originalRange)) { return aRequest; } else { return aRequest.changeSpan(adjustedRange[0], adjustedRange[1]); } }
@Override public CreateSpanAnnotationRequest onCreate(TypeAdapter aAdapter, CreateSpanAnnotationRequest aRequest) throws AnnotationException { if (aRequest.getBegin() == aRequest.getEnd()) { if (!aAdapter.getLayer().getAnchoringMode().isZeroSpanAllowed()) { throw new AnnotationException( "Cannot create zero-width annotation on layers that lock to token boundaries."); } return aRequest; } int[] originalRange = new int[] { aRequest.getBegin(), aRequest.getEnd() }; int[] adjustedRange = adjust(aRequest.getJcas(), aAdapter.getLayer().getAnchoringMode(), originalRange); if (adjustedRange.equals(originalRange)) { return aRequest; } else { return aRequest.changeSpan(adjustedRange[0], adjustedRange[1]); } }
@Override public CreateSpanAnnotationRequest onCreate(TypeAdapter aAdapter, CreateSpanAnnotationRequest aRequest) throws AnnotationException { if (aAdapter.getLayer().isAllowStacking()) { return aRequest; } final CAS aCas = aRequest.getJcas().getCas(); final int aBegin = aRequest.getBegin(); final int aEnd = aRequest.getEnd(); // If stacking is not allowed and there already is an annotation, then return the address // of the existing annotation. Type type = getType(aCas, aAdapter.getAnnotationTypeName()); for (AnnotationFS fs : selectCovered(aCas, type, aBegin, aEnd)) { if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) { throw new AnnotationException("Cannot create another annotation of layer [" + aAdapter.getLayer().getUiName() + "] at this location - stacking is not " + "enabled for this layer."); } } return aRequest; }
@Override public CreateSpanAnnotationRequest onCreate(TypeAdapter aAdapter, CreateSpanAnnotationRequest aRequest) throws AnnotationException { if (aAdapter.getLayer().isAllowStacking()) { return aRequest; } final CAS aCas = aRequest.getJcas().getCas(); final int aBegin = aRequest.getBegin(); final int aEnd = aRequest.getEnd(); // If stacking is not allowed and there already is an annotation, then return the address // of the existing annotation. Type type = getType(aCas, aAdapter.getAnnotationTypeName()); for (AnnotationFS fs : selectCovered(aCas, type, aBegin, aEnd)) { if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) { throw new AnnotationException("Cannot create another annotation of layer [" + aAdapter.getLayer().getUiName() + "] at this location - stacking is not " + "enabled for this layer."); } } return aRequest; }