| 
					
				 | 
			
			
				@@ -9,8 +9,8 @@ import com.tzld.piaoquan.recommend.server.service.rank.RankParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.service.rank.extractor.ExtractorUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.service.recall.strategy.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.service.score.ScorerUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.tzld.piaoquan.recommend.server.service.score.VovH24Weight562Scorer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.util.CommonCollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.tzld.piaoquan.recommend.server.util.SimilarityUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.collections4.MapUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.math3.util.Pair; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -29,23 +29,23 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ApolloJsonValue("${rank.score.merge.weightv564:}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Map<String, Double> mergeWeight; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @ApolloJsonValue("${rank.score.merge.weightv562:}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private Map<String, Double> mergeWeight562; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @ApolloJsonValue("${rank.score.merge.weightv567:}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private Map<String, Double> mergeWeight567; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private FeatureService featureService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Value("${similarity.concurrent: true}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private boolean similarityConcurrent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final List<String> shortPeriod = Arrays.asList("1h", "2h", "4h", "6h", "12h", "24h", "7d"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final List<String> middlePeriod = Arrays.asList("14d", "30d"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final List<String> longPeriod = Arrays.asList("7d", "35d", "90d", "365d"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final List<String> cfRosList = Collections.singletonList("rosn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final List<String> cfRovList = Collections.singletonList("rovn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final List<String> videoSimAttrs = Arrays.asList("cate2", "cate1_list", "keywords"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<Video> mergeAndRankRovRecall(RankParam param) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, Double> mergeWeight = this.mergeWeight != null ? this.mergeWeight : new HashMap<>(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, Double> mergeWeight562 = this.mergeWeight562 != null ? this.mergeWeight562 : new HashMap<>(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, Double> mergeWeight567 = this.mergeWeight567 != null ? this.mergeWeight567 : new HashMap<>(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //-------------------融------------------- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //-------------------合------------------- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //-------------------逻------------------- 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -90,11 +90,12 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // k1:视频、k2:表、k3:特征、v:特征值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String provinceCn = param.getProvince().replaceAll("省$", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String headVid = String.valueOf(param.getHeadVid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        FeatureService.Feature feature = featureService.getFeature(param.getMid(), vids, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                String.valueOf(param.getAppType()), provinceCn, headVid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String sceneType = String.valueOf(param.getHotSceneType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Map<String, Map<String, String>>> videoBaseInfoMap = featureService.getVideoBaseInfo(headVid, vids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FeatureService.Feature feature = featureService.getNewFeature(provinceCn, param.getMid(), sceneType, headVid, videoBaseInfoMap, vids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, Map<String, String>> featureOriginUser = feature.getUserFeature(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, Map<String, Map<String, String>>> featureOriginVideo = feature.getVideoFeature(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, String> headVideoInfo = videoBaseInfoMap.getOrDefault(headVid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 2 特征处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, Double> userFeatureMapDouble = new HashMap<>(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -225,7 +226,7 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Map<String, String> videoInfo = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, String> videoInfo = videoBaseInfoMap.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_basic_info", new HashMap<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             featureMap.put("total_time", Double.parseDouble(videoInfo.getOrDefault("total_time", "0"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             featureMap.put("bit_rate", Double.parseDouble(videoInfo.getOrDefault("bit_rate", "0"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -303,6 +304,11 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 featureMap.put("d1_return_n", Double.parseDouble(d1.getOrDefault("return_n", "0"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 featureMap.put("d1_rovn", Double.parseDouble(d1.getOrDefault("rovn", "0"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // ******************** new feature ******************** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            addVideoStatFeature(vid, featureOriginVideo, featureMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            addVideoCFFeature(vid, featureOriginVideo, featureMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            addVideoSimFeature(headVideoInfo, videoInfo, featureMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             item.featureMapDouble = featureMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -320,7 +326,6 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 userFeatureMap.put(name, String.valueOf(scoreNew)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (RankItem item : rankItems) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Map<String, String> featureMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Map<String, Double> featureMapDouble = item.featureMapDouble; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -338,70 +343,35 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             item.featureMap = featureMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // vovh24特征 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String partition = redisTemplate.opsForValue().get("redis:vid_vovh24pred_time:partition"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, Map<String, String>> vid2VovFeatureMap = this.getVideoRedisFeature(vids, "redis:vid_vovh24pred_time:" + partition + ":"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (RankItem rankItem : rankItems) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (vid2VovFeatureMap.containsKey(String.valueOf(rankItem.getVideoId()))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                rankItem.getFeatureMap().putAll(vid2VovFeatureMap.get(String.valueOf(rankItem.getVideoId()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 4 排序模型计算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<String, String> sceneFeatureMap = new HashMap<>(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (null != partition && partition.length() > 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            sceneFeatureMap.put("weightKey", partition.substring(partition.length() - 2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_20241119.conf").scoring(sceneFeatureMap, userFeatureMap, rankItems); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 562 vovScore 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, Map<String, String>> vov562FeatureMap = this.getVideoRedisFeature(vids, "redis:vid_vovhour4rank:"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        VovH24Weight562Scorer.scoring(mergeWeight562, vov562FeatureMap, items); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_20240807.conf").scoring(sceneFeatureMap, userFeatureMap, rankItems); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 5 排序公式特征 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, Map<String, String>> vid2MapFeature = this.getVideoRedisFeature(vids, "redis:vid_hasreturn_rov:"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        double alpha_vov = mergeWeight.getOrDefault("alpha_vov", 0.2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        double alpha_vov_562 = mergeWeight562.getOrDefault("alpha_vov", 1.0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        double alpha_vov_567 = mergeWeight567.getOrDefault("alpha_vov", 0.05); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        double func = mergeWeight.getOrDefault("func", 1.0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Map<String, String>> vid2MapFeature = this.getVideoRedisFeature(vids, "redis:vid_hasreturn_vor:"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<Video> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (RankItem item : items) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            item.getScoresMap().put("alpha_vov", alpha_vov); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            double score = 0.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            double score; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             double fmRovOrigin = item.getScoreRov(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             item.getScoresMap().put("fmRovOrigin", fmRovOrigin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             double fmRov = restoreScore(fmRovOrigin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             item.getScoresMap().put("fmRov", fmRov); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            double hasReturnRovScore = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("rate_n", "0")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            double hasReturnRovScore = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("rov", "0")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             item.getScoresMap().put("hasReturnRovScore", hasReturnRovScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            double vovScore = item.getVovScore(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            item.getScoresMap().put("vovScore", vovScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (func == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                score = fmRov * (1 + hasReturnRovScore) + alpha_vov * vovScore; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                score = fmRov * (1 + hasReturnRovScore) * (1.0 + alpha_vov * vovScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 562 && 567 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            double score562 = fmRov * (1 + hasReturnRovScore) * (1.0 + alpha_vov_562 * item.getScoresMap().getOrDefault("vovScore562", 0d)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            double score567 = fmRov * (1 + hasReturnRovScore) + alpha_vov_567 * item.getScoresMap().getOrDefault("vovScore567", 0d); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            item.getScoresMap().put("score562", score562); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            item.getScoresMap().put("score567", score567); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            double vor = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("vor", "0")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.getScoresMap().put("vor", vor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            score = fmRov * (0.1 + hasReturnRovScore) * (0.1 + vor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Video video = item.getVideo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             video.setScore(score); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             video.setSortScore(score); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             video.setScoresMap(item.getScoresMap()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             video.setAllFeatureMap(item.getAllFeatureMap()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (feature != null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    && MapUtils.isNotEmpty(feature.getVideoFeature()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    && MapUtils.isNotEmpty(feature.getVideoFeature().get(item.getVideoId() + ""))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (MapUtils.isNotEmpty(feature.getVideoFeature()) && MapUtils.isNotEmpty(feature.getVideoFeature().get(item.getVideoId() + ""))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 video.getMetaFeatureMap().putAll(feature.getVideoFeature().get(item.getVideoId() + "")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (feature != null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    && MapUtils.isNotEmpty(feature.getUserFeature())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (MapUtils.isNotEmpty(videoBaseInfoMap) && MapUtils.isNotEmpty(videoBaseInfoMap.get(item.getVideoId() + ""))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                video.getMetaFeatureMap().putAll(videoBaseInfoMap.get(item.getVideoId() + "")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (MapUtils.isNotEmpty(feature.getUserFeature())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 video.getMetaFeatureMap().putAll(feature.getUserFeature()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             result.add(video); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -409,4 +379,101 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         result.sort(Comparator.comparingDouble(o -> -o.getSortScore())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private Map<String, String> getVideoOneTypeInfo(String vid, String name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                    Map<String, Map<String, Map<String, String>>> videoAllInfoMap) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (null == videoAllInfoMap) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return videoAllInfoMap.getOrDefault(vid, new HashMap<>()).getOrDefault(name, new HashMap<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private double getVideoOneInfo(String name, Map<String, String> infoMap) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (null == infoMap) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return 0.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return infoMap.isEmpty() ? 0 : Double.parseDouble(infoMap.getOrDefault(name, "0.0")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void addVideoStatFeature(String vid, Map<String, Map<String, Map<String, String>>> videoAllInfoMap, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                     Map<String, Double> featureMap) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Tuple3> vidStatInfo = Arrays.asList( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("b20", shortPeriod, getVideoOneTypeInfo(vid, "alg_cate2_feature", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("b21", shortPeriod, getVideoOneTypeInfo(vid, "alg_cate1_feature", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("b22", shortPeriod, getVideoOneTypeInfo(vid, "alg_vid_source_feature", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("b28", shortPeriod, getVideoOneTypeInfo(vid, "alg_sence_type_feature", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("b23", middlePeriod, getVideoOneTypeInfo(vid, "alg_cate2_feature_day", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("b24", middlePeriod, getVideoOneTypeInfo(vid, "alg_cate1_feature_day", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("b25", middlePeriod, getVideoOneTypeInfo(vid, "alg_video_source_feature_day", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("b26", longPeriod, getVideoOneTypeInfo(vid, "alg_video_unionid_feature_day", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("b27", longPeriod, getVideoOneTypeInfo(vid, "alg_vid_feature_day", videoAllInfoMap)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (Tuple3 tuple3 : vidStatInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String infoType = tuple3.first; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<String> infoPeriod = tuple3.second; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, String> infoMap = tuple3.third; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (String period : infoPeriod) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double share = getVideoOneInfo("share_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double return_ = getVideoOneInfo("return_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double view_hasreturn = getVideoOneInfo("view_hasreturn_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double share_hasreturn = getVideoOneInfo("share_hasreturn_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double ros = getVideoOneInfo("ros_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double rov = getVideoOneInfo("rov_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double r_cnt = getVideoOneInfo("r_cnt_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double r_rate = getVideoOneInfo("r_rate_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double r_cnt4s = getVideoOneInfo("r_cnt4s_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                double str = getVideoOneInfo("str_" + period, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "share", ExtractorUtils.calLog(share)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "return", ExtractorUtils.calLog(return_)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "view_hasreturn", ExtractorUtils.calLog(view_hasreturn)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "share_hasreturn", ExtractorUtils.calLog(share_hasreturn)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "ros", ros); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "rov", rov); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "r_cnt", r_cnt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "r_rate", r_rate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "r_cnt4s", r_cnt4s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                featureMap.put(infoType + "_" + period + "_" + "str", str); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void addVideoCFFeature(String vid, Map<String, Map<String, Map<String, String>>> videoAllInfoMap, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                   Map<String, Double> featureMap) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Tuple3> vidCFInfo = Arrays.asList( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("d2", cfRosList, getVideoOneTypeInfo(vid, "alg_recsys_feature_weak_cf_i2i_scene_ros", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("d3", cfRosList, getVideoOneTypeInfo(vid, "alg_recsys_feature_cf_i2i_scene_ros", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("d4", cfRovList, getVideoOneTypeInfo(vid, "alg_recsys_feature_weak_cf_i2i_scene_rov", videoAllInfoMap)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Tuple3("d5", cfRovList, getVideoOneTypeInfo(vid, "alg_recsys_feature_cf_i2i_scene_rov", videoAllInfoMap)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (Tuple3 tuple3 : vidCFInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String infoType = tuple3.first; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<String> valTypeList = tuple3.second; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, String> infoMap = tuple3.third; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!infoMap.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (String valType : valTypeList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    double exp = getVideoOneInfo("exp", infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    double return_n = getVideoOneInfo("return_n", infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    double value = getVideoOneInfo(valType, infoMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    featureMap.put(infoType + "_exp", ExtractorUtils.calLog(exp)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    featureMap.put(infoType + "_return_n", ExtractorUtils.calLog(return_n)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    featureMap.put(infoType + "_" + valType, value); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void addVideoSimFeature(Map<String, String> headInfo, Map<String, String> rankInfo, Map<String, Double> featureMap) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!headInfo.isEmpty() && !rankInfo.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (String attr : videoSimAttrs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String headAttr = headInfo.getOrDefault(attr, ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String rankAttr = rankInfo.getOrDefault(attr, ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (!"".equals(headAttr) && !"".equals(rankAttr)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    double simScore = SimilarityUtils.word2VecSimilarity(headAttr, rankAttr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    featureMap.put("video_sim_" + attr, simScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |