use of org.vitrivr.cineast.core.data.score.ScoreElement in project cineast by vitrivr.
the class Lightfield method postprocessQuery.
/**
* This method represents the last step that's executed when processing a query. A list of partial-results (DistanceElements) returned by the lookup stage is processed based on some internal method and finally converted to a list of ScoreElements. The filtered list of ScoreElements is returned by the feature module during retrieval.
*
* @param partialResults List of partial results returned by the lookup stage.
* @param qc A ReadableQueryConfig object that contains query-related configuration parameters.
* @return List of final results. Is supposed to be de-duplicated and the number of items should not exceed the number of items per module.
*/
@Override
protected List<ScoreElement> postprocessQuery(List<SegmentDistanceElement> partialResults, ReadableQueryConfig qc) {
/* Perform search for each extracted feature and adjust scores. */
HashMap<String, DistanceElement> map = new HashMap<>();
for (DistanceElement result : partialResults) {
map.merge(result.getId(), result, (v1, v2) -> {
if (v1.getDistance() < v2.getDistance()) {
return v1;
} else {
return v2;
}
});
}
/* Add results to list and return list of results. */
final CorrespondenceFunction correspondence = qc.getCorrespondenceFunction().orElse(this.correspondence);
return ScoreElement.filterMaximumScores(map.entrySet().stream().map((e) -> e.getValue().toScore(correspondence)));
}
Aggregations