RecallConfigService.java
3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com.yoho.search.recall.config;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.recall.beans.strategy.SortBrandType;
import com.yoho.search.recall.beans.strategy.StrategyEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class RecallConfigService {
@Autowired
private RecallConfigServiceProduct recallConfigServiceProduct;
@Autowired
private RecallConfigServiceCommon recallConfigServiceCommon;
/**
* 获取召回数量
*
* @param pageId
* @param sortBrand
* @return
*/
public RecallSknCount queryRecallSknCount(int pageId, SortBrandType sortBrandType,SortBrand sortBrand) {
return recallConfigServiceProduct.queryRecallSknCount(pageId,sortBrandType,sortBrand);
}
/**
* 获取推荐的品类品牌的配置
*
* @param pageId
* @return
*/
public int getRecSortBrandCount(int pageId) {
return recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.REC_S_B_COUNT, 12);
}
/**
* 获取W2v预测的品类品牌的数量
*
* @param pageId
* @return
*/
public int getVectorW2vSortBrandCount(int pageId) {
return recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.VEC_W2V_S_B_COUNT, 12);
}
/**
* 获取RNN预测的品类品牌的数量
*
* @param pageId
* @return
*/
public int getVectorRNNSortBrandCount(int pageId) {
return recallConfigServiceCommon.queryConfigSize(pageId, RecallConfigConstants.VEC_RNN_S_B_COUNT, 0);
}
private String getStrategyConfiKey(StrategyEnum strategyEnum) {
if (strategyEnum.equals(StrategyEnum.REC_SKN)) {
return RecallConfigConstants.REC_SKN;
}
if (strategyEnum.equals(StrategyEnum.RT_SIM_SKN)) {
return RecallConfigConstants.RT_SIM_SKN;
}
if (strategyEnum.equals(StrategyEnum.DIRECT_TRAIN)) {
return RecallConfigConstants.DIRECT_TRAIN;
}
if (strategyEnum.equals(StrategyEnum.NEW_SHOP)) {
return RecallConfigConstants.NEW_SHOP;
}
if (strategyEnum.equals(StrategyEnum.ADD_FLOW)) {
return RecallConfigConstants.ADD_FLOW;
}
return null;
}
/**
* 获取某些策略的召回数量
*
* @param pageId
* @param strategyEnum
* @return
*/
public int queryStrategyRecallSknSize(int pageId, StrategyEnum strategyEnum) {
String configKey = getStrategyConfiKey(strategyEnum);
return recallConfigServiceCommon.queryConfigSize(pageId, configKey, 0);
}
/**
* 获取某些策略的间隔
*
* @param pageId
* @param strategyEnum
* @return
*/
public int queryStrategyInterval(int pageId, StrategyEnum strategyEnum) {
String configKey = getStrategyConfiKey(strategyEnum);
int interval = recallConfigServiceCommon.queryConfigInterval(pageId, configKey, 10);
interval = Math.max(interval, 2);
interval = Math.min(interval, 40);
return interval;
}
}