|
@@ -33,6 +33,12 @@ public class FeatureTransformV2 {
|
|
|
private static final List<String> userAttrList = Arrays.asList("province", "city", "model", "brand", "system", "user_channel", "user_level");
|
|
|
private static final Set<String> appSet = new HashSet<>(Arrays.asList("0", "2", "4"));
|
|
|
private static final Set<String> hotSceneSet = new HashSet<>(Arrays.asList("1008", "1007", "1058", "1074", "1010"));
|
|
|
+ private static final Map<String, String> histotyVideoAttrMAP = new HashMap<>();
|
|
|
+
|
|
|
+ static {
|
|
|
+ histotyVideoAttrMAP.put("merge_first_level_cate", "cate1");
|
|
|
+ histotyVideoAttrMAP.put("merge_second_level_cate", "cate2");
|
|
|
+ }
|
|
|
|
|
|
public static void getContextFeature(long currentMs, String appType, String hotSceneType, Map<String, Double> featureMap) {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
@@ -239,10 +245,11 @@ public class FeatureTransformV2 {
|
|
|
if (null == profile) {
|
|
|
return;
|
|
|
}
|
|
|
- getRSCrossFeature("c9_mss", currentMs, seqMaxN, profile.getM_s_s(), rankVideo, hVideoMap, featMap);
|
|
|
- getRSCrossFeature("c9_mrs", currentMs, seqMaxN, profile.getM_r_s(), rankVideo, hVideoMap, featMap);
|
|
|
- getRSCrossFeature("c9_lss", currentMs, seqLastN, profile.getL_s_s(), rankVideo, hVideoMap, featMap);
|
|
|
- getRSCrossFeature("c9_lrs", currentMs, seqLastN, profile.getL_r_s(), rankVideo, hVideoMap, featMap);
|
|
|
+ getRSCrossFeature(false, "c9_mss", currentMs, seqMaxN, profile.getM_s_s(), rankVideo, hVideoMap, featMap);
|
|
|
+ getRSCrossFeature(false, "c9_mrs", currentMs, seqMaxN, profile.getM_r_s(), rankVideo, hVideoMap, featMap);
|
|
|
+ getRSCrossFeature(true, "c9_lss", currentMs, seqLastN, profile.getL_s_s(), rankVideo, hVideoMap, featMap);
|
|
|
+ getRSCrossFeature(false, "c9_lrs", currentMs, seqLastN, profile.getL_r_s(), rankVideo, hVideoMap, featMap);
|
|
|
+ getRSCrossFeature(true, "c9_lr1s", currentMs, seqLastN, profile.getL_r1_s(), rankVideo, hVideoMap, featMap);
|
|
|
|
|
|
if (null == rankVideo || rankVideo.isEmpty()) {
|
|
|
return;
|
|
@@ -253,7 +260,7 @@ public class FeatureTransformV2 {
|
|
|
getVideoAttrSRCrossFeature("c9_l2s", rankVideo.getOrDefault("festive_label2", ""), profile.getL2_s(), featMap);
|
|
|
}
|
|
|
|
|
|
- private static void getRSCrossFeature(String prefix, long currentMs, int maxN, List<UserSRBO> list, Map<String, String> rankVideo, Map<String, Map<String, String>> hVideoMap, Map<String, Double> featMap) {
|
|
|
+ private static void getRSCrossFeature(boolean flag, String prefix, long currentMs, int maxN, List<UserSRBO> list, Map<String, String> rankVideo, Map<String, Map<String, String>> hVideoMap, Map<String, Double> featMap) {
|
|
|
if (null != list && !list.isEmpty()) {
|
|
|
for (int i = 0; i < list.size() && i < maxN; i++) {
|
|
|
UserSRBO u = list.get(i);
|
|
@@ -284,6 +291,9 @@ public class FeatureTransformV2 {
|
|
|
if (null != hVideoMap && hVideoMap.containsKey(vid)) {
|
|
|
Map<String, String> hVideo = hVideoMap.get(vid);
|
|
|
getTwoVideoCrossFeature(baseKey, hVideoSimAttrs, hVideo, rankVideo, featMap);
|
|
|
+ if (flag) {
|
|
|
+ getHistoryVideoCateFeature(baseKey, hVideo, featMap);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -561,4 +571,19 @@ public class FeatureTransformV2 {
|
|
|
}
|
|
|
return map.isEmpty() ? 0 : Double.parseDouble(map.getOrDefault(name, "0.0"));
|
|
|
}
|
|
|
+
|
|
|
+ private static void getHistoryVideoCateFeature(String prefix, Map<String, String> videoInfo, Map<String, Double> featMap) {
|
|
|
+ if (null == videoInfo || videoInfo.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, String> entry : histotyVideoAttrMAP.entrySet()) {
|
|
|
+ String attr = entry.getKey();
|
|
|
+ String attrVal = videoInfo.getOrDefault(attr, "");
|
|
|
+ attrVal = attrVal.trim();
|
|
|
+ if (!attrVal.isEmpty() && !attrVal.equals("unknown")) {
|
|
|
+ String key = String.format("%s@%s@%s", prefix, attr, attrVal);
|
|
|
+ featMap.put(key, 1.0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|