aState.getUser().getUsername(), jCas, sentence.getBegin() + i, sentence.getBegin() + i + selectedText.length() - 1)); adapter.setFeatureValue(aState.getDocument(), aState.getUser().getUsername(), jCas, addr, aFeature, aValue);
aState.getUser().getUsername(), jCas, sentence.getBegin() + i, sentence.getBegin() + i + selectedText.length() - 1)); adapter.setFeatureValue(aState.getDocument(), aState.getUser().getUsername(), jCas, addr, aFeature, aValue);
@Override public int upsertFeature(AnnotationSchemaService annotationService, SourceDocument aDocument, String aUsername, JCas aJCas, AnnotationLayer layer, AnnotationFeature aFeature, String aValue, int aBegin, int aEnd) throws AnnotationException { // The feature of the predicted label SpanAdapter adapter = (SpanAdapter) annotationService.getAdapter(layer); // Check if there is already an annotation of the target type at the given location Type type = CasUtil.getType(aJCas.getCas(), adapter.getAnnotationTypeName()); AnnotationFS annoFS = selectSingleFsAt(aJCas, type, aBegin, aEnd); int address; if (annoFS != null) { // ... if yes, then we update the feature on the existing annotation address = getAddr(annoFS); } else { // ... if not, then we create a new annotation - this also takes care of attaching to // an annotation if necessary address = getAddr(adapter.add(aDocument, aUsername, aJCas, aBegin, aEnd)); } // Update the feature value adapter.setFeatureValue(aDocument, aUsername, aJCas, address, aFeature, aValue); return address; }
/** * Copy this same annotation from the user annotation to the mergeview */ private static void copySpanAnnotation(AnnotatorState aState, AnnotationSchemaService aAnnotationService, AnnotationLayer aAnnotationLayer, AnnotationFS aOldFs, JCas aJCas) throws AnnotationException { SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aAnnotationLayer); // Create the annotation - this also takes care of attaching to an annotation if necessary int id = getAddr(adapter.add(aState.getDocument(), aState.getUser().getUsername(), aJCas, aOldFs.getBegin(), aOldFs.getEnd())); List<AnnotationFeature> features = aAnnotationService .listAnnotationFeature(adapter.getLayer()); // Copy the features for (AnnotationFeature feature : features) { Type oldType = adapter.getAnnotationType(aOldFs.getCAS()); Feature oldFeature = oldType.getFeatureByBaseName(feature.getName()); if (isLinkOrBasicFeatures(aOldFs, oldFeature)) { continue; } Object value = adapter.getFeatureValue(feature, aOldFs); adapter.setFeatureValue(aState.getDocument(), aState.getUser().getUsername(), aJCas, id, feature, value); } }
/** * Copy this same annotation from the user annotation to the mergeview */ private static void copySpanAnnotation(AnnotatorState aState, AnnotationSchemaService aAnnotationService, AnnotationLayer aAnnotationLayer, AnnotationFS aOldFs, JCas aJCas) throws AnnotationException { SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aAnnotationLayer); // Create the annotation - this also takes care of attaching to an annotation if necessary int id = getAddr(adapter.add(aState.getDocument(), aState.getUser().getUsername(), aJCas, aOldFs.getBegin(), aOldFs.getEnd())); List<AnnotationFeature> features = aAnnotationService .listAnnotationFeature(adapter.getLayer()); // Copy the features for (AnnotationFeature feature : features) { Type oldType = adapter.getAnnotationType(aOldFs.getCAS()); Feature oldFeature = oldType.getFeatureByBaseName(feature.getName()); if (isLinkOrBasicFeatures(aOldFs, oldFeature)) { continue; } Object value = adapter.getFeatureValue(feature, aOldFs); adapter.setFeatureValue(aState.getDocument(), aState.getUser().getUsername(), aJCas, id, feature, value); } }