public CreateSpanAnnotationRequest changeSpan(int aBegin, int aEnd) { return new CreateSpanAnnotationRequest(this, document, username, jcas, aBegin, aEnd); } }
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; }
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]); } }
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; }
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 CreateSpanAnnotationRequest changeSpan(int aBegin, int aEnd) { return new CreateSpanAnnotationRequest(this, document, username, jcas, aBegin, aEnd); } }
@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 addSpan(SourceDocument aDocument, String aUsername, JCas aJCas, int aBegin, int aEnd) throws AnnotationException { return handle(new CreateSpanAnnotationRequest(aDocument, aUsername, aJCas, aBegin, aEnd)); }
@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 addSpan(SourceDocument aDocument, String aUsername, JCas aJCas, int aBegin, int aEnd) throws AnnotationException { return handle(new CreateSpanAnnotationRequest(aDocument, aUsername, aJCas, aBegin, aEnd)); }
@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; }
/** * Add new span annotation into the CAS and return the the id of the span annotation * * @param aDocument * the document to which the CAS belongs * @param aUsername * the user to which the CAS belongs * @param aJCas * the JCas. * @param aBegin * the begin offset. * @param aEnd * the end offset. * @return the ID. * @throws AnnotationException * if the annotation cannot be created/updated. */ public AnnotationFS add(SourceDocument aDocument, String aUsername, JCas aJCas, int aBegin, int aEnd) throws AnnotationException { return handle(new CreateSpanAnnotationRequest(aDocument, aUsername, aJCas, aBegin, aEnd)); }
@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; }
/** * Add new span annotation into the CAS and return the the id of the span annotation * * @param aDocument * the document to which the CAS belongs * @param aUsername * the user to which the CAS belongs * @param aJCas * the JCas. * @param aBegin * the begin offset. * @param aEnd * the end offset. * @return the ID. * @throws AnnotationException * if the annotation cannot be created/updated. */ public AnnotationFS add(SourceDocument aDocument, String aUsername, JCas aJCas, int aBegin, int aEnd) throws AnnotationException { return handle(new CreateSpanAnnotationRequest(aDocument, aUsername, aJCas, aBegin, aEnd)); }