001/**
002 * AskingAndProposingPreferenceElicitation.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 * 05/11/2007
008 */
009package es.ucm.fdi.gaia.jcolibri.extensions.recommendation.askingAndProposing;
010
011
012import java.util.Collection;
013import java.util.HashMap;
014import java.util.Map;
015
016import es.ucm.fdi.gaia.jcolibri.cbrcore.Attribute;
017import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRCase;
018import es.ucm.fdi.gaia.jcolibri.cbrcore.CBRQuery;
019import es.ucm.fdi.gaia.jcolibri.exception.ExecutionException;
020import es.ucm.fdi.gaia.jcolibri.extensions.recommendation.navigationByAsking.ObtainQueryWithAttributeQuestionMethod;
021import es.ucm.fdi.gaia.jcolibri.extensions.recommendation.navigationByAsking.SelectAttributeMethod;
022import es.ucm.fdi.gaia.jcolibri.extensions.recommendation.navigationByProposing.CriticalUserChoice;
023import es.ucm.fdi.gaia.jcolibri.extensions.recommendation.navigationByProposing.queryElicitation.MoreLikeThis;
024
025/**
026 * Method that implements the Preference elicitation task for the Expert Clerk system.<br>
027 * See recommender 8 for details.<br>
028 * In NbA it elicits the query asking for the value of an attribute.<br>
029 * In NbP it uses the MoreLikeThis method.
030 * 
031 * @author Juan A. Recio-Garcia
032 * @author Developed at University College Cork (Ireland) in collaboration with Derek Bridge.
033 * @version 1.0
034 */
035public class AskingAndProposingPreferenceElicitation
036{
037    
038    private static DisplayCasesIfNumberAndChangeNavigation.NavigationMode mode = DisplayCasesIfNumberAndChangeNavigation.NavigationMode.NBA;
039    
040    /** 
041     * Changes the navigation type.
042     */
043    public static void changeTo(DisplayCasesIfNumberAndChangeNavigation.NavigationMode _mode)
044    {
045        mode = _mode;
046    }
047    
048    /**
049     * Executes the preference elicitation. <br>
050     * If NbA mode it obtains a new query using the ObtainQueryWithAttributeQuestionMethod.<br>
051     * If NBP mode it revises the query using MoreLikeThis.<br> 
052     * @param query to elicit
053     * @param cases is the working cases set
054     * @param sam is the method used to obtain the next attribute to ask (only in NbA mode).
055     * @param cuc is the user critique in NbP mode.
056     * @throws ExecutionException if any error.
057     */
058    public static void doPreferenceElicitation(CBRQuery query, Collection<CBRCase> cases, SelectAttributeMethod sam, CriticalUserChoice cuc) throws ExecutionException
059    {
060        if(mode == DisplayCasesIfNumberAndChangeNavigation.NavigationMode.NBA)
061        {
062            Attribute att = sam.getAttribute(cases, query);
063            Map<Attribute,String> labels = new HashMap<Attribute,String>();
064            ObtainQueryWithAttributeQuestionMethod.obtainQueryWithAttributeQuestion(query, att, labels,cases);
065        } 
066        else if(mode == DisplayCasesIfNumberAndChangeNavigation.NavigationMode.NBP)
067        {
068            new MoreLikeThis().reviseQuery(query, cuc.getSelectedCase(), cases);
069        }
070
071    }
072}