es.ucm.fdi.gaia.jcolibri.method.retrieve.selection.SelectCases Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jCOLIBRI Show documentation
Show all versions of jCOLIBRI Show documentation
jCOLIBRI is a java framework for the development of Case-Based Reasoning systems.
/**
* SelectCases.java
* jCOLIBRI2 framework.
* @author Juan A. Recio-Garc�a.
* GAIA - Group for Artificial Intelligence Applications
* http://gaia.fdi.ucm.es
* 24/11/2007
*/
package es.ucm.fdi.gaia.jcolibri.method.retrieve.selection;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase;
import es.ucm.fdi.gaia.jcolibri.method.retrieve.RetrievalResult;
/**
* Class that stores the selectAll and selectTopK methods.
*
* @author Juan A. Recio-Garcia
* @author Developed at University College Cork (Ireland) in collaboration with Derek Bridge.
* @version 2.0
*/
public class SelectCases {
/**
* Selects all cases
* @param cases to select
* @return all cases
*/
public static Collection selectAll(Collection cases) {
List res = cases.stream()
.map(RetrievalResult::get_case)
.collect(Collectors.toList());
return res;
}
/**
* Selects top K cases
* @param cases to select
* @param k is the number of csaes to select
* @return top k cases
*/
public static Collection selectTopK(Collection cases, int k) {
List res = cases.stream()
.limit(k)
.map(RetrievalResult::get_case)
.collect(Collectors.toList());
return res;
}
/**
* Selects all cases but returns them into RetrievalResult objects
* @param cases to select
* @return all cases into RetrievalResult objects
*/
public static Collection selectAllRR(Collection cases) {
return cases;
}
/**
* Selects top k cases but returns them into RetrievalResult objects
* @param cases to select
* @return top k cases into RetrievalResult objects
*/
public static Collection selectTopKRR(Collection cases, int k) {
List res = cases.stream()
.limit(k)
.collect(Collectors.toList());
return res;
}
}