|
@@ -1,6 +1,7 @@
|
|
|
package com.tzld.piaoquan.recommend.server.service.rank.strategy;
|
|
|
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
+import com.google.common.reflect.TypeToken;
|
|
|
import com.tzld.piaoquan.recommend.server.common.ThreadPoolFactory;
|
|
|
import com.tzld.piaoquan.recommend.server.common.base.RankItem;
|
|
|
import com.tzld.piaoquan.recommend.server.model.Video;
|
|
@@ -10,6 +11,7 @@ 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.util.CommonCollectionUtils;
|
|
|
+import com.tzld.piaoquan.recommend.server.util.JSONUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.commons.math3.util.Pair;
|
|
@@ -20,6 +22,7 @@ import java.util.*;
|
|
|
import java.util.concurrent.Future;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -309,7 +312,7 @@ public class RankStrategy4RegionMergeModelV562 extends RankStrategy4RegionMergeM
|
|
|
Map<String, String> sceneFeatureMap = new HashMap<>(0);
|
|
|
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_vor:");
|
|
|
+ Map<String, Map<String, String>> vid2MapFeature = this.getVideoRedisFeature(vids, "redis:fea_hasreturn_vor:");
|
|
|
List<Video> result = new ArrayList<>();
|
|
|
for (RankItem item : items) {
|
|
|
double score;
|
|
@@ -317,9 +320,9 @@ public class RankStrategy4RegionMergeModelV562 extends RankStrategy4RegionMergeM
|
|
|
item.getScoresMap().put("fmRovOrigin", fmRovOrigin);
|
|
|
double fmRov = restoreScore(fmRovOrigin);
|
|
|
item.getScoresMap().put("fmRov", fmRov);
|
|
|
- double hasReturnRovScore = this.calcHasReturnRovScore(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()));
|
|
|
+ double hasReturnRovScore = this.calcHasReturnRovScore(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()), param.getHotSceneType().toString(), item);
|
|
|
item.getScoresMap().put("hasReturnRovScore", hasReturnRovScore);
|
|
|
- double vor = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("vor", "0"));
|
|
|
+ double vor = this.calcVorScore(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()));
|
|
|
item.getScoresMap().put("vor", vor);
|
|
|
score = fmRov * (0.1 + hasReturnRovScore) * (0.1 + vor);
|
|
|
Video video = item.getVideo();
|
|
@@ -339,7 +342,38 @@ public class RankStrategy4RegionMergeModelV562 extends RankStrategy4RegionMergeM
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private double calcHasReturnRovScore(Map<String, String> feature){
|
|
|
- return Double.parseDouble(feature.getOrDefault("rov", "0"));
|
|
|
+ private double calcHasReturnRovScore(Map<String, String> feature, String hotSceneType, RankItem item) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ Map<String, String> hotSceneJson = JSONUtils.fromJson(feature.getOrDefault(hotSceneType, "{}"), new TypeToken<Map<String, String>>() {
|
|
|
+ }, new HashMap<>());
|
|
|
+ Map<String, String> sumJson = JSONUtils.fromJson(feature.getOrDefault("sum", "{}"), new TypeToken<Map<String, String>>() {
|
|
|
+ }, new HashMap<>());
|
|
|
+
|
|
|
+ String hotSceneHasReturn = hotSceneJson.getOrDefault("hasreturn", "0");
|
|
|
+ String sumHasReturn = sumJson.getOrDefault("hasreturn", "0");
|
|
|
+
|
|
|
+ item.getScoresMap().put("hotSceneHasReturn", Double.parseDouble(hotSceneHasReturn));
|
|
|
+ item.getScoresMap().put("sumHasReturn", Double.parseDouble(sumHasReturn));
|
|
|
+
|
|
|
+ return Stream.of(hotSceneHasReturn, sumHasReturn)
|
|
|
+ .mapToDouble(Double::parseDouble)
|
|
|
+ .average().orElse(0.0);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("[562 exp] calc has return rov score error: {}, {}", feature, hotSceneType, e);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private double calcVorScore(Map<String, String> feature) {
|
|
|
+ try {
|
|
|
+ Map<String, String> sumJson = JSONUtils.fromJson(feature.getOrDefault("sum", "{}"), new TypeToken<Map<String, String>>() {
|
|
|
+ }, new HashMap<>());
|
|
|
+ return Double.parseDouble(sumJson.getOrDefault("vor", "0"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("[562 exp] calc vor score error: {}", feature, e);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|
|
|
}
|