private void setHighlight(LearningRecord aRecord) { LOG.trace("Active learning sidebar set highlight history record: {}", aRecord); highlightVID = null; highlightSpan = new Offset(aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd()); highlightDocumentName = aRecord.getSourceDocument().getName(); // This is a bit of hack. Consider the following case: // - use removes an ACCEPT history item // - user clicks then on another history item // - ... but during the subsequent rendering the "moveToNextSuggestion" method sets or // clears the highlight. protectHighlight = true; }
private void setHighlight(LearningRecord aRecord) { LOG.trace("Active learning sidebar set highlight history record: {}", aRecord); highlightVID = null; highlightSpan = new Offset(aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd()); highlightDocumentName = aRecord.getSourceDocument().getName(); // This is a bit of hack. Consider the following case: // - use removes an ACCEPT history item // - user clicks then on another history item // - ... but during the subsequent rendering the "moveToNextSuggestion" method sets or // clears the highlight. protectHighlight = true; }
private Optional<AnnotationFS> getMatchingAnnotation(CAS aCas, LearningRecord aRecord) { Type type = CasUtil.getType(aCas, alStateModel.getObject().getLayer().getName()); Feature feature = type.getFeatureByBaseName(aRecord.getAnnotationFeature().getName()); return selectAt(aCas, type, aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd()).stream() .filter(fs -> aRecord.getAnnotation().equals(fs.getFeatureValueAsString(feature))) .findFirst(); }
private Optional<AnnotationFS> getMatchingAnnotation(CAS aCas, LearningRecord aRecord) { Type type = CasUtil.getType(aCas, alStateModel.getObject().getLayer().getName()); Feature feature = type.getFeatureByBaseName(aRecord.getAnnotationFeature().getName()); return selectAt(aCas, type, aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd()).stream() .filter(fs -> aRecord.getAnnotation().equals(fs.getFeatureValueAsString(feature))) .findFirst(); }
private void deleteAnnotationByHistory(AjaxRequestTarget aTarget, LearningRecord aRecord) throws IOException, AnnotationException { AnnotatorState state = getModelObject(); JCas jCas = this.getJCasProvider().get(); Optional<AnnotationFS> anno = getMatchingAnnotation(jCas.getCas(), aRecord); if (anno.isPresent()) { state.getSelection().selectSpan(new VID(anno.get()), jCas, aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd()); getActionHandler().actionDelete(aTarget); } }
private void deleteAnnotationByHistory(AjaxRequestTarget aTarget, LearningRecord aRecord) throws IOException, AnnotationException { AnnotatorState state = getModelObject(); JCas jCas = this.getJCasProvider().get(); Optional<AnnotationFS> anno = getMatchingAnnotation(jCas.getCas(), aRecord); if (anno.isPresent()) { state.getSelection().selectSpan(new VID(anno.get()), jCas, aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd()); getActionHandler().actionDelete(aTarget); } }
@Override public boolean isSuggestionVisible(LearningRecord aRecord) { User user = userService.get(aRecord.getUser()); List<SuggestionGroup> suggestions = getSuggestions(user, aRecord.getLayer()); for (SuggestionGroup listOfAO : suggestions) { if (listOfAO.stream().anyMatch(suggestion -> suggestion.getDocumentName().equals(aRecord.getSourceDocument().getName()) && suggestion.getFeature().equals(aRecord.getAnnotationFeature().getName()) && suggestion.getLabel().equals(aRecord.getAnnotation()) && suggestion.getBegin() == aRecord.getOffsetCharacterBegin() && suggestion.getEnd() == aRecord.getOffsetCharacterEnd() && suggestion.isVisible()) ) { return true; } } return false; }
@Override public boolean isSuggestionVisible(LearningRecord aRecord) { User user = userService.get(aRecord.getUser()); List<SuggestionGroup> suggestions = getSuggestions(user, aRecord.getLayer()); for (SuggestionGroup listOfAO : suggestions) { if (listOfAO.stream().anyMatch(suggestion -> suggestion.getDocumentName().equals(aRecord.getSourceDocument().getName()) && suggestion.getFeature().equals(aRecord.getAnnotationFeature().getName()) && suggestion.getLabel().equals(aRecord.getAnnotation()) && suggestion.getBegin() == aRecord.getOffsetCharacterBegin() && suggestion.getEnd() == aRecord.getOffsetCharacterEnd() && suggestion.isVisible()) ) { return true; } } return false; }
.filter(r -> r.getSourceDocument().getName().equals(s.getDocumentName()) && r.getOffsetCharacterBegin() == s.getBegin() && r.getOffsetCharacterEnd() == s.getEnd() && r.getAnnotation().equals(s.getLabel())) .forEach(record -> {
.filter(r -> r.getSourceDocument().getName().equals(s.getDocumentName()) && r.getOffsetCharacterBegin() == s.getBegin() && r.getOffsetCharacterEnd() == s.getEnd() && r.getAnnotation().equals(s.getLabel())) .forEach(record -> {
private List<AnnotationSuggestion> getMatchingSuggestion(List<SuggestionGroup> aSuggestions, LearningRecord aRecord) { return getMatchingSuggestion(aSuggestions, aRecord.getSourceDocument().getName(), aRecord.getLayer().getId(), aRecord.getAnnotationFeature().getName(), aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd(), aRecord.getAnnotation()); }
private List<AnnotationSuggestion> getMatchingSuggestion(List<SuggestionGroup> aSuggestions, LearningRecord aRecord) { return getMatchingSuggestion(aSuggestions, aRecord.getSourceDocument().getName(), aRecord.getLayer().getId(), aRecord.getAnnotationFeature().getName(), aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd(), aRecord.getAnnotation()); }
aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd());
&& record.getOffsetCharacterEnd() == aSuggestion.getEnd() && record.getAnnotation().equals(aSuggestion.getLabel()))
aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd());
if (getMatchingAnnotation(jCas.getCas(), aRecord).isPresent()) { actionShowSelectedDocument(aTarget, aRecord.getSourceDocument(), aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd()); confirmationDialog.setTitleModel(new StringResourceModel( "alSidebar.history.delete.confirmation.title", this));
if (getMatchingAnnotation(jCas.getCas(), aRecord).isPresent()) { actionShowSelectedDocument(aTarget, aRecord.getSourceDocument(), aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd()); confirmationDialog.setTitleModel(new StringResourceModel( "alSidebar.history.delete.confirmation.title", this));