org.codelibs.elasticsearch.taste.recommender.ItemBasedRecommenderBuilder Maven / Gradle / Ivy
package org.codelibs.elasticsearch.taste.recommender;
import java.util.HashMap;
import java.util.Map;
import org.codelibs.elasticsearch.taste.model.DataModel;
import org.codelibs.elasticsearch.taste.model.IndexInfo;
import org.codelibs.elasticsearch.taste.similarity.ItemSimilarity;
import org.codelibs.elasticsearch.util.settings.SettingsUtils;
public class ItemBasedRecommenderBuilder extends AbstractRecommenderBuilder {
public ItemBasedRecommenderBuilder(final IndexInfo indexInfo,
final Map rootSettings) {
super(indexInfo, rootSettings);
}
@Override
public Recommender buildRecommender(final DataModel dataModel) {
final Map similaritySettings = SettingsUtils.get(
rootSettings, "similarity", new HashMap());
similaritySettings.put(DATA_MODEL_ATTR, dataModel);
final ItemSimilarity similarity = createSimilarity(similaritySettings);
return new GenericItemBasedRecommender(dataModel, similarity);
}
}