All Downloads are FREE. Search and download functionalities are using the official Maven repository.

es.ucm.fdi.gaia.jcolibri.method.retrieve.selection.SelectCases Maven / Gradle / Ivy

Go to download

jCOLIBRI is a java framework for the development of Case-Based Reasoning systems.

There is a newer version: 3.2
Show newest version
/**
 * 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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy