@@ -0,0 +1,1669 @@
+package com.uwetrottmann.shopr.context.algorithm;%0A%0Aimport com.uwetrottmann.shopr.algorithm.model.Item;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created by yannick on 17.02.15.%0A *%0A * In this class the post-filtering of the recommended cases is done. We will retrieve several different%0A * items from the recommendation algorithm. Based on the current active context and the contexts in which these items%0A * were selected, there is going to be a re-ordered list of the top x items.%0A */%0Apublic class ContextualPostFiltering %7B%0A%0A    /**%0A     * This method shall postFilter the provided item set of the case base in order to return better recommendations.%0A     * Therefore it takes a list of current preferred items by the algorithm and searches for contexts in which this item%0A     * was selected. It then checks these contexts with the current context and compares them based on the context's distance metric.%0A     *%0A     * @param currentRecommendation the current recommendations as set by the algorithm%0A     * @param numberOfRecommendations the number of recommendations that should be outputted%0A     * @return an updated list with only the number of items that should be outputted.%0A     */%0A    public static List%3CItem%3E postFilterItems(List%3CItem%3E currentRecommendation, int numberOfRecommendations)%7B%0A        List%3CItem%3E updatedRecommendation = new ArrayList%3CItem%3E();%0A%0A        for (Item item : currentRecommendation)%7B%0A            if (updatedRecommendation.size() %3C numberOfRecommendations) %7B%0A                updatedRecommendation.add(item);%0A            %7D else %7B%0A                break;%0A            %7D%0A        %7D%0A%0A        return updatedRecommendation;%0A    %7D%0A%7D

Build skeleton of context-algorithm for post-filtering