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