public static List<Type> getEntryTypes(JCas mergeJCas, List<AnnotationLayer> aLayers, AnnotationSchemaService aAnnotationService) { List<Type> entryTypes = new LinkedList<>(); for (AnnotationLayer layer : aLayers) { if (layer.getName().equals(Token.class.getName())) { continue; } if (layer.getType().equals(WebAnnoConst.CHAIN_TYPE)) { continue; } entryTypes.add( aAnnotationService.getAdapter(layer).getAnnotationType(mergeJCas.getCas())); } return entryTypes; }
public static List<Type> getEntryTypes(JCas mergeJCas, List<AnnotationLayer> aLayers, AnnotationSchemaService aAnnotationService) { List<Type> entryTypes = new LinkedList<>(); for (AnnotationLayer layer : aLayers) { if (layer.getName().equals(Token.class.getName())) { continue; } if (layer.getType().equals(WebAnnoConst.CHAIN_TYPE)) { continue; } entryTypes.add( aAnnotationService.getAdapter(layer).getAnnotationType(mergeJCas.getCas())); } return entryTypes; }
private void actionCreate(AjaxRequestTarget aTarget) throws AnnotationException, IOException { DocumentMetadataLayerAdapter adapter = (DocumentMetadataLayerAdapter) annotationService .getAdapter(selectedLayer.getObject()); JCas jcas = jcasProvider.get(); AnnotationBaseFS fs = adapter.add(sourceDocument.getObject(), username.getObject(), jcas); detailPanel.setModelObject(new VID(fs)); annotationPage.writeEditorCas(jcas); aTarget.add(this); aTarget.add(detailPanel); }
private void actionCreate(AjaxRequestTarget aTarget) throws AnnotationException, IOException { DocumentMetadataLayerAdapter adapter = (DocumentMetadataLayerAdapter) annotationService .getAdapter(selectedLayer.getObject()); JCas jcas = jcasProvider.get(); AnnotationBaseFS fs = adapter.add(sourceDocument.getObject(), username.getObject(), jcas); detailPanel.setModelObject(new VID(fs)); annotationPage.writeEditorCas(jcas); aTarget.add(this); aTarget.add(detailPanel); }
TypeAdapter adapter = aAnnotationService.getAdapter(feature.getLayer()); for (SourceDocument document : aRepository.listSourceDocuments(feature.getProject())) { File predFile = new File(miraDir, document.getId() + ".pred.ft");
TypeAdapter adapter = annotationService.getAdapter(layer); Renderer renderer = layerSupportRegistry.getLayerSupport(layer).getRenderer(layer);
TypeAdapter adapter = annotationService.getAdapter(layer);
JCas jCas = aCorrectionDocumentService.readCorrectionCas(d); TypeAdapter adapter = aAnnotationService.getAdapter(aFeature.getLayer());
private void actionDelete(AjaxRequestTarget aTarget) { try { // Load the boiler-plate JCas jCas = jcasProvider.get(); AnnotationBaseFS fs = selectByAddr(jCas, AnnotationBaseFS.class, getModelObject().getId()); AnnotationLayer layer = annotationService.getLayer(project.getObject(), fs); TypeAdapter adapter = annotationService.getAdapter(layer); // Perform actual actions adapter.delete(sourceDocument.getObject(), username.getObject(), jCas, new VID(fs)); // persist changes annotationPage.writeEditorCas(jCas); setModelObject(null); aTarget.add(getParent()); } catch (Exception e) { handleException(DocumentMetadataAnnotationDetailPanel.this, aTarget, e); } }
private void actionDelete(AjaxRequestTarget aTarget) { try { // Load the boiler-plate JCas jCas = jcasProvider.get(); AnnotationBaseFS fs = selectByAddr(jCas, AnnotationBaseFS.class, getModelObject().getId()); AnnotationLayer layer = annotationService.getLayer(project.getObject(), fs); TypeAdapter adapter = annotationService.getAdapter(layer); // Perform actual actions adapter.delete(sourceDocument.getObject(), username.getObject(), jCas, new VID(fs)); // persist changes annotationPage.writeEditorCas(jCas); setModelObject(null); aTarget.add(getParent()); } catch (Exception e) { handleException(DocumentMetadataAnnotationDetailPanel.this, aTarget, e); } }
public static Map<Integer, String> getMultipleAnnotation( AnnotationSchemaService aAnnotationService, Sentence sentence, AnnotationFeature aFeature) throws CASException { SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aFeature.getLayer()); Map<Integer, String> multAnno = new HashMap<>(); Type type = getType(sentence.getCAS(), adapter.getAnnotationTypeName()); for (AnnotationFS fs : selectCovered(type, sentence)) { boolean isBegin = true; Feature labelFeature = fs.getType().getFeatureByBaseName(aFeature.getName()); for (Token token : selectCovered(Token.class, fs)) { if (multAnno.get(getAddr(token)) == null) { if (isBegin) { multAnno.put(getAddr(token), "B-" + fs.getFeatureValueAsString(labelFeature)); isBegin = false; } else { multAnno.put(getAddr(token), "I-" + fs.getFeatureValueAsString(labelFeature)); } } } } return multAnno; }
public static Map<Integer, String> getMultipleAnnotation( AnnotationSchemaService aAnnotationService, Sentence sentence, AnnotationFeature aFeature) throws CASException { SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aFeature.getLayer()); Map<Integer, String> multAnno = new HashMap<>(); Type type = getType(sentence.getCAS(), adapter.getAnnotationTypeName()); for (AnnotationFS fs : selectCovered(type, sentence)) { boolean isBegin = true; Feature labelFeature = fs.getType().getFeatureByBaseName(aFeature.getName()); for (Token token : selectCovered(Token.class, fs)) { if (multAnno.get(getAddr(token)) == null) { if (isBegin) { multAnno.put(getAddr(token), "B-" + fs.getFeatureValueAsString(labelFeature)); isBegin = false; } else { multAnno.put(getAddr(token), "I-" + fs.getFeatureValueAsString(labelFeature)); } } } } return multAnno; }
private Set<AnnotationFS> getAttachedSpans(AnnotationFS aFs, AnnotationLayer aLayer) { CAS cas = aFs.getCAS(); Set<AnnotationFS> attachedSpans = new HashSet<>(); TypeAdapter adapter = annotationService.getAdapter(aLayer); if (adapter instanceof SpanAdapter && aLayer.getAttachType() != null) { Type spanType = CasUtil.getType(cas, aLayer.getAttachType().getName()); Feature attachFeature = spanType.getFeatureByBaseName(aLayer.getAttachFeature() .getName()); for (AnnotationFS attachedFs : selectAt(cas, spanType, aFs.getBegin(), aFs.getEnd())) { if (isSame(attachedFs.getFeatureValue(attachFeature), aFs)) { attachedSpans.add(attachedFs); } } } return attachedSpans; }
private void actionAnnotate(AjaxRequestTarget aTarget) { try { // When updating an annotation in the sidebar, we must not force a // re-focus after rendering getRequestCycle().setMetaData(IsSidebarAction.INSTANCE, true); // Load the boiler-plate JCas jCas = jcasProvider.get(); AnnotationBaseFS fs = selectByAddr(jCas, AnnotationBaseFS.class, getModelObject().getId()); AnnotationLayer layer = annotationService.getLayer(project.getObject(), fs); TypeAdapter adapter = annotationService.getAdapter(layer); // Update the features of the selected annotation from the values presently in // the feature editors writeFeatureEditorModelsToCas(adapter, jCas); // persist changes annotationPage.writeEditorCas(jCas); } catch (Exception e) { handleException(DocumentMetadataAnnotationDetailPanel.this, aTarget, e); } }
SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aFeature.getLayer()); for (SourceDocument d : aDocumentService.listSourceDocuments(aState.getProject())) { loadDocument(d, aAnnotationService, aDocumentService, aCorrectionDocumentService,
private void actionAnnotate(AjaxRequestTarget aTarget) { try { // When updating an annotation in the sidebar, we must not force a // re-focus after rendering getRequestCycle().setMetaData(IsSidebarAction.INSTANCE, true); // Load the boiler-plate JCas jCas = jcasProvider.get(); AnnotationBaseFS fs = selectByAddr(jCas, AnnotationBaseFS.class, getModelObject().getId()); AnnotationLayer layer = annotationService.getLayer(project.getObject(), fs); TypeAdapter adapter = annotationService.getAdapter(layer); // Update the features of the selected annotation from the values presently in // the feature editors writeFeatureEditorModelsToCas(adapter, jCas); // persist changes annotationPage.writeEditorCas(jCas); } catch (Exception e) { handleException(DocumentMetadataAnnotationDetailPanel.this, aTarget, e); } }
@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); } }
TypeAdapter adapter = annotationService.getAdapter(layer);