es.uam.eps.ir.ranksys.diversity.intentaware.AspectModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of RankSys-diversity Show documentation
Show all versions of RankSys-diversity Show documentation
RankSys module, providing diversity metrics and enhancement techniques.
The newest version!
/*
* Copyright (C) 2015 RankSys (http://ranksys.org)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package es.uam.eps.ir.ranksys.diversity.intentaware;
import es.uam.eps.ir.ranksys.core.model.UserModel;
import org.ranksys.core.util.tuples.Tuple2od;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
/**
* Aspect model for the intent-aware diversification framework. User intents
* are taken from the intent model.
*
* @author Jacek Wasilewski ([email protected])
*
* @param user type
* @param item type
* @param aspect type
*/
public abstract class AspectModel extends UserModel {
/**
* Intent model
*/
protected IntentModel intentModel;
/**
* Constructor taking the intent model
*
* @param intentModel intent model
*/
public AspectModel(IntentModel intentModel) {
this.intentModel = intentModel;
}
@SuppressWarnings("unchecked")
@Override
public UserAspectModel getModel(U user) {
return (UserAspectModel) super.getModel(user);
}
/**
* User aspect model for {@link AspectModel}.
*/
public abstract class UserAspectModel implements IntentModel.UserIntentModel,
ItemAspectModel {
private final IntentModel.UserIntentModel uim;
/**
* Constructor taking user intent model.
*
* @param user user
*/
public UserAspectModel(U user) {
this.uim = intentModel.getModel(user);
}
/**
* Initialises the model with items.
*
* @param items list of items with scores
*/
public abstract void initializeWithItems(List> items);
@Override
public Set getIntents() {
return uim.getIntents();
}
@Override
public Stream getItemIntents(I i) {
return uim.getItemIntents(i);
}
@Override
public double pf_u(F f) {
return uim.pf_u(f);
}
}
/**
* Item aspect model for {@link AspectModel}.
*
* @param user type
* @param item type
* @param aspect type
*/
public interface ItemAspectModel extends Model {
/**
* Returns probability of an item given an aspect
*
* @param iv item-value pair
* @param f aspect
* @return probability of an item given an aspect
*/
public abstract double pi_f(Tuple2od iv, F f);
}
}