/** * TODO #176 use the document Id once it it available in the CAS * * Get the predictions of a given window, where the outer list is a list of tokens and the inner * list is a list of predictions for a token */ public SuggestionDocumentGroup getPredictions(String aDocumentName, AnnotationLayer aLayer, int aWindowBegin, int aWindowEnd) { return new SuggestionDocumentGroup(getFlattenedPredictions(aDocumentName, aLayer, aWindowBegin, aWindowEnd)); }
@Override public List<SuggestionGroup> getSuggestions(User aUser, AnnotationLayer aLayer) { Predictions model = recommendationService.getPredictions(aUser, aLayer.getProject()); if (model == null) { return Collections.emptyList(); } Map<String, SuggestionDocumentGroup> recommendationsMap = model .getPredictionsForWholeProject(aLayer, documentService); return recommendationsMap.values().stream() .flatMap(docMap -> docMap.stream()) .collect(toList()); }
@Override public boolean add(SuggestionGroup aGroup) { boolean empty = isEmpty(); if (!empty) { Validate.isTrue(documentName.equals(aGroup.getDocumentName()), "All suggestions in a group must come from the same document: expected [%s] but got [%s]", documentName, aGroup.getDocumentName()); } // Cache information that must be consistent in the group when the first item is added if (empty) { documentName = aGroup.getDocumentName(); } return groups.add(aGroup); }
if (groups.isEmpty()) { return;
@Override public List<SuggestionGroup> getSuggestions(User aUser, AnnotationLayer aLayer) { Predictions model = recommendationService.getPredictions(aUser, aLayer.getProject()); if (model == null) { return Collections.emptyList(); } Map<String, SuggestionDocumentGroup> recommendationsMap = model .getPredictionsForWholeProject(aLayer, documentService); return recommendationsMap.values().stream() .flatMap(docMap -> docMap.stream()) .collect(toList()); }