|
|
@@ -606,6 +606,58 @@ public class FeatureV6 {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 提取 c9 序列特征的 String 原始值(week/hour/cate1/cate2),供 DNN 模型使用。
|
|
|
+ * 离线 FG 编码直接取原始值(如 week="3"),在线也需要对齐。
|
|
|
+ */
|
|
|
+ public static void putProfileVideoCrossStringFeature(long currentMs, UserShareReturnProfile profile,
|
|
|
+ Map<String, Map<String, String>> hVideoMap,
|
|
|
+ Map<String, String> featureMapString) {
|
|
|
+ if (null == profile) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ putRSCrossStringFeature(false, "c9_mss", currentMs, seqMaxN, profile.getM_s_s(), hVideoMap, featureMapString);
|
|
|
+ putRSCrossStringFeature(false, "c9_mrs", currentMs, seqMaxN, profile.getM_r_s(), hVideoMap, featureMapString);
|
|
|
+ putRSCrossStringFeature(true, "c9_lss", currentMs, seqLastN, profile.getL_s_s(), hVideoMap, featureMapString);
|
|
|
+ putRSCrossStringFeature(false, "c9_lrs", currentMs, seqLastN, profile.getL_r_s(), hVideoMap, featureMapString);
|
|
|
+ putRSCrossStringFeature(true, "c9_lr1s", currentMs, seqLastN, profile.getL_r1_s(), hVideoMap, featureMapString);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void putRSCrossStringFeature(boolean hasCate, String prefix, long currentMs, int maxN,
|
|
|
+ List<UserSRBO> list, Map<String, Map<String, String>> hVideoMap,
|
|
|
+ Map<String, String> featureMapString) {
|
|
|
+ if (null == list || list.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < list.size() && i < maxN; i++) {
|
|
|
+ UserSRBO u = list.get(i);
|
|
|
+ if (null == u) continue;
|
|
|
+ long id = u.getId();
|
|
|
+ long ts = u.getTs();
|
|
|
+ if (id <= 0) continue;
|
|
|
+
|
|
|
+ String baseKey = String.format("%s@%d", prefix, i + 1);
|
|
|
+
|
|
|
+ // week & hour
|
|
|
+ if (ts > 0) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTimeInMillis(ts * 1000);
|
|
|
+ featureMapString.put(baseKey + "_week", String.valueOf(calendar.get(Calendar.DAY_OF_WEEK)));
|
|
|
+ featureMapString.put(baseKey + "_hour", String.valueOf(calendar.get(Calendar.HOUR_OF_DAY) + 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ // cate1 & cate2
|
|
|
+ if (hasCate && null != hVideoMap) {
|
|
|
+ String vid = id + "";
|
|
|
+ Map<String, String> hVideo = hVideoMap.getOrDefault(vid, new HashMap<>());
|
|
|
+ String cate1 = hVideo.getOrDefault("merge_first_level_cate", "").trim();
|
|
|
+ String cate2 = hVideo.getOrDefault("merge_second_level_cate", "").trim();
|
|
|
+ featureMapString.put(baseKey + "_cate1", (!cate1.isEmpty() && !cate1.equals("unknown")) ? cate1 : "");
|
|
|
+ featureMapString.put(baseKey + "_cate2", (!cate2.isEmpty() && !cate2.equals("unknown")) ? cate2 : "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static void putVideoStringFeatures(String prefix, Map<String, String> videoInfo, Map<String, String> featureMapToString) {
|
|
|
featureMapToString.put(prefix + "@resolution", videoInfo.getOrDefault("resolution", ""));
|
|
|
featureMapToString.put(prefix + "@time_type", videoInfo.getOrDefault("time_type", ""));
|