本文整理汇总了Java中org.easyrec.service.domain.TypeMappingService.getIdOfViewType方法的典型用法代码示例。如果您正苦于以下问题:Java TypeMappingService.getIdOfViewType方法的具体用法?Java TypeMappingService.getIdOfViewType怎么用?Java TypeMappingService.getIdOfViewType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.easyrec.service.domain.TypeMappingService
的用法示例。
在下文中一共展示了TypeMappingService.getIdOfViewType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import org.easyrec.service.domain.TypeMappingService; //导入方法依赖的package包/类
@Override
protected void doExecute(final ExecutionControl control, GeneratorStatistics stats) throws Exception {
TypeMappingService typeMappingService = (TypeMappingService) getTypeMappingService();
ItemItemConfiguration configuration = getConfiguration();
final Integer tenantId = configuration.getTenantId();
final Integer actionTypeId = typeMappingService.getIdOfActionType(tenantId, configuration.getActionType());
final Integer itemTypeId = typeMappingService.getIdOfItemType(tenantId, configuration.getItemType());
final Integer assocTypeId = typeMappingService.getIdOfAssocType(tenantId, configuration.getAssociationType());
final Integer viewTypeId = typeMappingService.getIdOfViewType(tenantId, configuration.getViewType());
final String sourceType = ID + "/" + VERSION;
final Integer sourceTypeId = typeMappingService.getIdOfSourceType(tenantId, sourceType);
final Date changeDate = new Date();
stats.setStartDate(changeDate);
TenantVO tenant = getTenantService().getTenantById(tenantId);
SimilarityCalculationStrategy similarityCalculationStrategy = similarityCalculationTypes
.get(configuration.getSimilarityType());
similarityCalculationStrategy.setItemAssocService(itemAssocService);
similarityCalculationStrategy.setActionDAO(actionDAO);
PredictionComputationStrategy predictionComputationStrategy = predictionComputationTypes
.get(configuration.getPredictionType());
predictionComputationStrategy.setActionDAO(actionDAO);
predictionComputationStrategy.setUserAssocDAO(userAssocDAO);
itemItemService.setSimilarityCalculationStrategy(similarityCalculationStrategy);
itemItemService.setPredictionComputationStrategy(predictionComputationStrategy);
itemItemService.setConfiguration(configuration);
// generate actions
if (control.isAbortRequested()) return;
control.updateProgress(new Progress(1, 4, "Generating actions"));
int generatedActions = actionDAO.generateActions(tenantId, null);
stats.setNumberOfActionsConsidered(generatedActions);
// similarity calculation
if (control.isAbortRequested()) return;
control.updateProgress(new Progress(2, 4, "Calculating similarity"));
itemItemService.calculateSimilarity(tenantId, actionTypeId, itemTypeId, assocTypeId, viewTypeId, sourceTypeId,
changeDate, stats, control);
// prediction generation
if (control.isAbortRequested()) return;
control.updateProgress(new Progress(3, 4, "Calculating predictions"));
/* removed for now because user->item associations are not yet enabled
itemItemService.predict(tenantId, actionTypeId, itemTypeId, assocTypeId, viewTypeId, sourceTypeId, changeDate,
similarityCalculationStrategy.getSourceInfo(), tenant.getRatingRangeMin(), tenant.getRatingRangeMax(),
control); */
control.updateProgress(new Progress(4, 4, "Finished"));
stats.setEndDateToNow();
}
示例2: doExecute
import org.easyrec.service.domain.TypeMappingService; //导入方法依赖的package包/类
@Override
protected void doExecute(ExecutionControl executionControl, MahoutSlopeoneGeneratorStats stats) throws Exception {
// when doExecute() is called, the generator has been initialized with the configuration we should use
Date execution = new Date();
MahoutSlopeoneGeneratorConfig config = getConfiguration();
TypeMappingService typeMappingService = (TypeMappingService) super.getTypeMappingService();
ItemAssocService itemAssocService = getItemAssocService();
EasyrecDataModel easyrecDataModel = new EasyrecDataModel(config.getTenantId(), typeMappingService.getIdOfActionType(config.getTenantId(), config.getActionType()), true, mahoutDataModelMappingDAO);
Recommender recommender = new SlopeOneRecommender(easyrecDataModel);
itemTypeDAO.insertOrUpdate(config.getTenantId(), "USER", false);
Integer assocType = typeMappingService.getIdOfAssocType(config.getTenantId(), config.getAssociationType());
Integer userType = typeMappingService.getIdOfItemType(config.getTenantId(), "USER");
Integer sourceType = typeMappingService.getIdOfSourceType(config.getTenantId(), getSourceType());
Integer viewType = typeMappingService.getIdOfViewType(config.getTenantId(), config.getViewType());
stats.setNumberOfItems(easyrecDataModel.getNumItems());
for (LongPrimitiveIterator it = easyrecDataModel.getUserIDs(); it.hasNext(); ) {
long userId = it.nextLong();
List<RecommendedItem> recommendations = recommender.recommend(userId, config.getNumberOfRecs());
if (recommendations.isEmpty()) {
logger.debug("User " + userId + " : no recommendations");
}
// print the list of recommendations for each
for (RecommendedItem recommendedItem : recommendations) {
logger.debug("User " + userId + " : " + recommendedItem);
Integer itemToId = (int) recommendedItem.getItemID();
Integer itemToType = itemDAO.getItemTypeIdOfItem(config.getTenantId(), itemToId);
ItemVO<Integer, Integer> fromItem = new ItemVO<Integer, Integer>(config.getTenantId(), (int) userId, userType);
Double recommendationStrength = (double) recommendedItem.getValue();
ItemVO<Integer, Integer> toItem = new ItemVO<Integer, Integer>(config.getTenantId(), itemToId, itemToType);
ItemAssocVO<Integer,Integer> itemAssoc = new ItemAssocVO<Integer,Integer>(
config.getTenantId(), fromItem, assocType, recommendationStrength, toItem, sourceType,
"Mahout Slopeone Generator", viewType, null, execution);
itemAssocService.insertOrUpdateItemAssoc(itemAssoc);
stats.incNumberOfRulesCreated();
}
}
}