public Relation(int aId, String aType, List<Argument> aArguments, String aLabelText, String aColor) { this(new VID(aId), aType, aArguments, aLabelText, aColor); }
@Deprecated public int getId() { return vid.getId(); }
public boolean isNotSet() { return !isSet(); }
@Override public void onRender(TypeAdapter aAdapter, VDocument aResponse, Map<AnnotationFS, VArc> aAnnoToArcIdx) { if (aAdapter.getLayer().isCrossSentence()) { return; } try { for (Entry<AnnotationFS, VArc> e : aAnnoToArcIdx.entrySet()) { JCas jcas = e.getKey().getCAS().getJCas(); if (!isBeginInSameSentence(jcas, selectByAddr(jcas, e.getValue().getSource().getId()).getBegin(), selectByAddr(jcas, e.getValue().getTarget().getId()).getBegin())) { aResponse.add(new VComment(new VID(e.getKey()), ERROR, "Crossing sentence bounardies is not permitted.")); } } } catch (CASException e) { throw new IllegalStateException("Unable to obtain JCas"); } }
private void assertParseVid(String aExtensionId, int aLayerId, int aAnnotationID, int aSubAnnotationId, int aAttribute, int aSlot, String aVID) { VID a = VID.parse(aVID); assertEquals(aExtensionId, a.getExtensionId()); assertEquals(aLayerId, a.getLayerId()); assertEquals(aAnnotationID, a.getId()); assertEquals(aSubAnnotationId, a.getSubId()); assertEquals(aAttribute, a.getAttribute()); assertEquals(aSlot, a.getSlot()); } }
@Test public void test() { assertEquals("10", new VID(10).toString()); assertEquals("10.1", new VID(10, 1).toString()); assertEquals("10.1.2", new VID(10, 1, 2).toString()); assertEquals("10-1.2.3", new VID(10, 1, 2, 3).toString()); assertEquals("ext:10-1.2.3", new VID("ext", 10, 1, 2, 3).toString()); assertEquals("ext:10-1.2.3@1", new VID("ext", 1, 10, 1, 2, 3).toString()); assertEquals(VID.NONE_ID.toString(), VID.parse(VID.NONE_ID.toString()).toString()); assertEquals("10", VID.parse("10").toString()); assertEquals("10.1", VID.parse("10.1").toString()); assertEquals("10.1.2", VID.parse("10.1.2").toString()); assertEquals("10-1.2.3", VID.parse("10-1.2.3").toString()); assertEquals("ext:10-1.2.3", VID.parse("ext:10-1.2.3").toString()); assertEquals("ext:10-1.2.3@1", VID.parse("ext:10-1.2.3@1").toString()); }
private Label createSelectedAnnotationTypeLabel() { Label label = new Label("selectedAnnotationType", LoadableDetachableModel.of(() -> { try { return String.valueOf(WebAnnoCasUtil.selectByAddr(editorPanel.getEditorCas(), getModelObject().getSelection().getAnnotation().getId())).trim(); } catch (IOException e) { return ""; } })); label.setOutputMarkupPlaceholderTag(true); // We show the extended info on the selected annotation only when run in development mode label.add(visibleWhen(() -> getModelObject().getSelection().getAnnotation().isSet() && DEVELOPMENT.equals(getApplication().getConfigurationType()))); return label; }
/** * Extract offset information from the current request. These are either offsets of an existing * selected annotations or offsets contained in the request for the creation of a new * annotation. */ private Offsets getOffsetsFromRequest(IRequestParameters request, JCas jCas, VID aVid) throws IOException { if (aVid.isNotSet() || aVid.isSynthetic()) { // Create new span annotation - in this case we get the offset information from the // request String offsets = request.getParameterValue(PARAM_OFFSETS).toString(); OffsetsList offsetLists = JSONUtil.getObjectMapper().readValue(offsets, OffsetsList.class); int annotationBegin = getModelObject().getWindowBeginOffset() + offsetLists.get(0).getBegin(); int annotationEnd = getModelObject().getWindowBeginOffset() + offsetLists.get(offsetLists.size() - 1).getEnd(); return new Offsets(annotationBegin, annotationEnd); } else { // Edit existing span annotation - in this case we look up the offsets in the CAS // Let's not trust the client in this case. AnnotationFS fs = WebAnnoCasUtil.selectByAddr(jCas, aVid.getId()); return new Offsets(fs.getBegin(), fs.getEnd()); } }
Recommender recommender = recommendationService.getRecommender(aVID.getId()); AnnotationLayer layer = annotationService.getLayer(aVID.getLayerId()); AnnotationFeature feature = recommender.getFeature();
private void internalCompleteAnnotation(AjaxRequestTarget aTarget, JCas aJCas) { AnnotatorState state = getModelObject(); // Perform auto-scroll if it is enabled if (state.getPreferences().isScrollPage()) { autoScroll(aJCas, false); } annotationFeatureForm.getForwardAnnotationText().setModelObject(null); LOG.trace("onChange()"); onChange(aTarget); // If we created a new annotation, then refresh the available annotation layers in the // detail panel. if (state.getSelection().getAnnotation().isNotSet()) { refresh(state); } }
vid.getLayerId() == alStateModel.getObject().getLayer().getId() && prediction.get().equals( alStateModel.getObject().getSuggestion().orElse(null))
private SpanAnnotationResponse actionSpan(AjaxRequestTarget aTarget, IRequestParameters request, JCas jCas, VID paramId) throws IOException, AnnotationException { Offsets offsets = getOffsetsFromRequest(request, jCas, paramId); AnnotatorState state = getModelObject(); Selection selection = state.getSelection(); if (state.isSlotArmed()) { // When filling a slot, the current selection is *NOT* changed. The // Span annotation which owns the slot that is being filled remains // selected! getActionHandler().actionFillSlot(aTarget, jCas, offsets.getBegin(), offsets.getEnd(), paramId); } else { if (!paramId.isSynthetic()) { selection.selectSpan(paramId, jCas, offsets.getBegin(), offsets.getEnd()); if (selection.getAnnotation().isNotSet()) { // Create new annotation getActionHandler().actionCreateOrUpdate(aTarget, jCas); } else { getActionHandler().actionSelect(aTarget, jCas); } } } return new SpanAnnotationResponse(); }
@Override public void onRender(TypeAdapter aAdapter, VDocument aResponse, Map<AnnotationFS, VArc> aAnnoToArcIdx) { if (aAdapter.getLayer().isCrossSentence()) { return; } try { for (Entry<AnnotationFS, VArc> e : aAnnoToArcIdx.entrySet()) { JCas jcas = e.getKey().getCAS().getJCas(); if (!isBeginInSameSentence(jcas, selectByAddr(jcas, e.getValue().getSource().getId()).getBegin(), selectByAddr(jcas, e.getValue().getTarget().getId()).getBegin())) { aResponse.add(new VComment(new VID(e.getKey()), ERROR, "Crossing sentence bounardies is not permitted.")); } } } catch (CASException e) { throw new IllegalStateException("Unable to obtain JCas"); } }
+ featureState.value); aAdapter.setFeatureValue(state.getDocument(), state.getUser().getUsername(), aJCas, state.getSelection().getAnnotation().getId(), featureState.feature, featureState.value); if (state.getSelection().getAnnotation().isSet()) { String bratLabelText = TypeUtil.getUiLabelText(aAdapter, selectByAddr(aJCas, state.getSelection().getAnnotation().getId()), features); info(generateMessage(state.getSelectedAnnotationLayer(), bratLabelText, false));