001/**
002 * DisplayCasesIfSimilarity.java
003 * jCOLIBRI2 framework. 
004 * @author Juan A. Recio-Garc�a.
005 * GAIA - Group for Artificial Intelligence Applications
006 * http://gaia.fdi.ucm.es
007 * 31/10/2007
008 */
009package es.ucm.fdi.gaia.jcolibri.extensions.recommendation.conditionals;
010
011
012import java.util.List;
013
014import es.ucm.fdi.gaia.jcolibri.method.retrieve.RetrievalResult;
015
016/**
017 * Conditional method that returns true if the retrieved cases
018 * have a minimum similarity
019 * 
020 * @author Juan A. Recio-Garcia
021 * @author Developed at University College Cork (Ireland) in collaboration with Derek Bridge.
022 * @version 1.0
023 *
024 */
025public class DisplayCasesIfSimilarity
026{
027    /**
028     * Checks if cases should be displayed checking the minimum similarity of all them.
029     * @param retrieval set of cases
030     * @param minSimil min similarity value
031     * @return true if all them have a higher similarity than minSimil.
032     */
033    public static boolean displayCasesIfAllHaveMinimumSimilarity(List<RetrievalResult> retrieval, double minSimil)
034    {
035        for(RetrievalResult rr: retrieval)
036            if(rr.getEval() < minSimil)
037                return false;
038        return true;
039    }
040    
041    /**
042     * Checks if cases should be displayed checking the minimum similarity of them.
043     * This method returns true if just one case has a higher similarity.
044     * @param retrieval set of cases
045     * @param minSimil min similarity value
046     * @return true if any of them has a higher similarity than minSimil.
047     */
048    public static boolean displayCasesIfAnyHaveMinimumSimilarity(List<RetrievalResult> retrieval, double minSimil)
049    {
050        for(RetrievalResult rr: retrieval)
051            if(rr.getEval() >= minSimil)
052                return true;
053        return false;
054    }
055}