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); } }
Map<AnnotationFS, VSpan> aAnnoToSpanIdx) if (aAdapter.getLayer().isAllowStacking() || aAnnoToSpanIdx.isEmpty()) { return;
Map<AnnotationFS, VSpan> aAnnoToSpanIdx) if (aAdapter.getLayer().isAllowStacking() || aAnnoToSpanIdx.isEmpty()) { return;
@Override public List<Pair<LogMessage, AnnotationFS>> onValidate(TypeAdapter aAdapter, JCas aJCas) { if (aAdapter.getLayer().isAllowStacking()) { return emptyList(); } CAS cas = aJCas.getCas(); Type type = getType(cas, aAdapter.getAnnotationTypeName()); AnnotationFS prevFS = null; List<Pair<LogMessage, AnnotationFS>> messages = new ArrayList<>(); // Since the annotations are sorted, we can easily find stacked annotation by scanning // through the entire list and checking if two adjacent annotations have the same offsets for (AnnotationFS fs : select(cas, type)) { if (prevFS != null && prevFS.getBegin() == fs.getBegin() && prevFS.getEnd() == fs.getEnd()) { messages.add(Pair.of(LogMessage.error(this, "Stacked annotation at [%d-%d]", fs.getBegin(), fs.getEnd()), fs)); } prevFS = fs; } return messages; } }
@Override public List<Pair<LogMessage, AnnotationFS>> onValidate(TypeAdapter aAdapter, JCas aJCas) { if (aAdapter.getLayer().isAllowStacking()) { return emptyList(); } CAS cas = aJCas.getCas(); Type type = getType(cas, aAdapter.getAnnotationTypeName()); AnnotationFS prevFS = null; List<Pair<LogMessage, AnnotationFS>> messages = new ArrayList<>(); // Since the annotations are sorted, we can easily find stacked annotation by scanning // through the entire list and checking if two adjacent annotations have the same offsets for (AnnotationFS fs : select(cas, type)) { if (prevFS != null && prevFS.getBegin() == fs.getBegin() && prevFS.getEnd() == fs.getEnd()) { messages.add(Pair.of(LogMessage.error(this, "Stacked annotation at [%d-%d]", fs.getBegin(), fs.getEnd()), fs)); } prevFS = fs; } return messages; } }
String label = annotation.getFeatureValueAsString(feat); for (AnnotationSuggestion suggestion : group) { if (!aLayer.isAllowStacking() || label.equals(suggestion.getLabel())) { suggestion.hide(FLAG_OVERLAP);
if (!layer.isAllowStacking()) { int[] adjustedRange = SpanAnchoringModeBehavior.adjust(aJCas, layer.getAnchoringMode(), new int[] { selection.getBegin(),
SpanAdapter adapter = new SpanAdapter(aLayer); adapter.setLockToTokenOffsets(aLayer.isLockToTokenOffset()); adapter.setAllowStacking(aLayer.isAllowStacking()); adapter.setAllowMultipleToken(aLayer.isMultipleTokens()); adapter.setCrossMultipleSentence(aLayer.isCrossSentence()); adapter.setAllowStacking(aLayer.isAllowStacking());
@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; }
exLayer.setAllowStacking(aLayer.isAllowStacking()); exLayer.setBuiltIn(aLayer.isBuiltIn()); exLayer.setReadonly(aLayer.isReadonly());
exLayer.setAllowStacking(aLayer.isAllowStacking()); exLayer.setBuiltIn(aLayer.isBuiltIn()); exLayer.setReadonly(aLayer.isReadonly());
throws AnnotationException if (aAdapter.getLayer().isAllowStacking()) { return aRequest;
throws AnnotationException if (aAdapter.getLayer().isAllowStacking()) { return aRequest;
exLayer.setAllowStacking(aLayer.isAllowStacking()); exLayer.setBuiltIn(aLayer.isBuiltIn()); exLayer.setCrossSentence(aLayer.isCrossSentence());
private void createSpan(String spanType, AnnotatorState aBModel, JCas aMergeJCas, AnnotationDocument aAnnotationDocument, int aAddress) throws IOException, UIMAException, ClassNotFoundException, AnnotationException { JCas clickedJCas = getJCas(aBModel, aAnnotationDocument); AnnotationFS fsClicked = selectByAddr(clickedJCas, aAddress); if (isCorefType(fsClicked)) { throw new AnnotationException("Coreference Annotation not supported in curation"); } long layerId = TypeUtil.getLayerId(spanType); AnnotationLayer layer = annotationService.getLayer(layerId); MergeCas.addSpanAnnotation(aBModel, annotationService, layer, aMergeJCas, fsClicked, layer.isAllowStacking()); writeEditorCas(aBModel, aMergeJCas); // update timestamp int sentenceNumber = getSentenceNumber(clickedJCas, fsClicked.getBegin()); aBModel.setFocusUnitIndex(sentenceNumber); aBModel.getDocument().setSentenceAccessed(sentenceNumber); if (aBModel.getPreferences().isScrollPage()) { Sentence sentence = selectSentenceAt(aMergeJCas, aBModel.getFirstVisibleUnitBegin(), aBModel.getFirstVisibleUnitEnd()); sentence = findWindowStartCenteringOnSelection(aMergeJCas, sentence, fsClicked.getBegin(), aBModel.getProject(), aBModel.getDocument(), aBModel.getPreferences().getWindowSize()); aBModel.setFirstVisibleUnit(sentence); } }
exLayer.setAllowStacking(aLayer.isAllowStacking()); exLayer.setBuiltIn(aLayer.isBuiltIn()); exLayer.setReadonly(aLayer.isReadonly());
private void createSpan(String spanType, AnnotatorState aBModel, JCas aMergeJCas, AnnotationDocument aAnnotationDocument, int aAddress) throws IOException, UIMAException, ClassNotFoundException, AnnotationException { JCas clickedJCas = getJCas(aBModel, aAnnotationDocument); AnnotationFS fsClicked = selectByAddr(clickedJCas, aAddress); if (isCorefType(fsClicked)) { throw new AnnotationException("Coreference Annotation not supported in curation"); } long layerId = TypeUtil.getLayerId(spanType); AnnotationLayer layer = annotationService.getLayer(layerId); MergeCas.addSpanAnnotation(aBModel, annotationService, layer, aMergeJCas, fsClicked, layer.isAllowStacking()); writeEditorCas(aBModel, aMergeJCas); // update timestamp int sentenceNumber = getSentenceNumber(clickedJCas, fsClicked.getBegin()); aBModel.setFocusUnitIndex(sentenceNumber); aBModel.getDocument().setSentenceAccessed(sentenceNumber); if (aBModel.getPreferences().isScrollPage()) { Sentence sentence = selectSentenceAt(aMergeJCas, aBModel.getFirstVisibleUnitBegin(), aBModel.getFirstVisibleUnitEnd()); sentence = findWindowStartCenteringOnSelection(aMergeJCas, sentence, fsClicked.getBegin(), aBModel.getProject(), aBModel.getDocument(), aBModel.getPreferences().getWindowSize()); aBModel.setFirstVisibleUnit(sentence); } }
exLayer.setAllowStacking(aLayer.isAllowStacking()); exLayer.setBuiltIn(aLayer.isBuiltIn()); exLayer.setReadonly(aLayer.isReadonly());