|
@@ -1,6 +1,7 @@
|
|
|
package com.tzld.piaoquan.recommend.server.service.rank.strategy;
|
|
|
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
+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;
|
|
|
import com.tzld.piaoquan.recommend.server.service.FeatureService;
|
|
@@ -8,17 +9,18 @@ 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 lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
+import org.apache.commons.math3.util.Pair;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.io.BufferedReader;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.InputStreamReader;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.Future;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -27,15 +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;
|
|
|
|
|
|
- Map<String, double[]> bucketsMap = new HashMap<>();
|
|
|
- Map<String, Double> bucketsLen = new HashMap<>();
|
|
|
+ @Value("${similarity.concurrent: true}")
|
|
|
+ private boolean similarityConcurrent;
|
|
|
|
|
|
@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);
|
|
|
//-------------------融-------------------
|
|
|
//-------------------合-------------------
|
|
|
//-------------------逻-------------------
|
|
@@ -58,24 +68,23 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
|
|
|
List<Video> rovRecallRank = new ArrayList<>(v0);
|
|
|
//-------------------return相似召回------------------
|
|
|
List<Video> v6 = extractAndSort(param, ReturnVideoRecallStrategy.PUSH_FORM);
|
|
|
- v6 = v6.stream().filter(r-> !setVideo.contains(r.getVideoId())).collect(Collectors.toList());
|
|
|
+ v6 = v6.stream().filter(r -> !setVideo.contains(r.getVideoId())).collect(Collectors.toList());
|
|
|
v6 = v6.subList(0, Math.min(mergeWeight.getOrDefault("v6", 5.0).intValue(), v6.size()));
|
|
|
rovRecallRank.addAll(v6);
|
|
|
setVideo.addAll(v6.stream().map(Video::getVideoId).collect(Collectors.toSet()));
|
|
|
//-------------------新地域召回------------------
|
|
|
List<Video> v1 = extractAndSort(param, RegionRealtimeRecallStrategyV1.PUSH_FORM);
|
|
|
- v1 = v1.stream().filter(r-> !setVideo.contains(r.getVideoId())).collect(Collectors.toList());
|
|
|
+ v1 = v1.stream().filter(r -> !setVideo.contains(r.getVideoId())).collect(Collectors.toList());
|
|
|
v1 = v1.subList(0, Math.min(mergeWeight.getOrDefault("v1", 5.0).intValue(), v1.size()));
|
|
|
rovRecallRank.addAll(v1);
|
|
|
setVideo.addAll(v1.stream().map(Video::getVideoId).collect(Collectors.toSet()));
|
|
|
|
|
|
-
|
|
|
//-------------------排-------------------
|
|
|
//-------------------序-------------------
|
|
|
//-------------------逻-------------------
|
|
|
//-------------------辑-------------------
|
|
|
|
|
|
- // TODO 1 批量获取特征 省份参数要对齐 headvid 要传递过来!
|
|
|
+ // 1 批量获取特征 省份参数要对齐 headvid 要传递过来!
|
|
|
List<String> vids = CommonCollectionUtils.toListDistinct(rovRecallRank, v -> String.valueOf(v.getVideoId()));
|
|
|
|
|
|
// k1:视频、k2:表、k3:特征、v:特征值
|
|
@@ -87,7 +96,7 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
|
|
|
Map<String, Map<String, Map<String, String>>> featureOriginVideo = feature.getVideoFeature();
|
|
|
|
|
|
|
|
|
- // TODO 2 特征处理
|
|
|
+ // 2 特征处理
|
|
|
Map<String, Double> userFeatureMapDouble = new HashMap<>();
|
|
|
String mid = param.getMid();
|
|
|
Map<String, String> c1 = featureOriginUser.getOrDefault("alg_mid_feature_play", new HashMap<>());
|
|
@@ -95,8 +104,8 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
|
|
|
Map<String, String> c3 = featureOriginUser.getOrDefault("alg_mid_feature_play_tags", new HashMap<>());
|
|
|
Map<String, String> c4 = featureOriginUser.getOrDefault("alg_mid_feature_return_tags", new HashMap<>());
|
|
|
Map<String, String> c5 = featureOriginUser.getOrDefault("alg_mid_feature_share_tags", new HashMap<>());
|
|
|
- Map<String, String> c6 = featureOriginUser.getOrDefault("alg_mid_feature_feed_exp_share_tags", new HashMap<>());
|
|
|
- Map<String, String> c7 = featureOriginUser.getOrDefault("alg_mid_feature_feed_exp_return_tags", new HashMap<>());
|
|
|
+ Map<String, String> c6 = featureOriginUser.getOrDefault("alg_mid_feature_feed_exp_share_tags_v2", new HashMap<>());
|
|
|
+ Map<String, String> c7 = featureOriginUser.getOrDefault("alg_mid_feature_feed_exp_return_tags_v2", new HashMap<>());
|
|
|
Map<String, String> c8 = featureOriginUser.getOrDefault("alg_mid_feature_sharecf", new HashMap<>());
|
|
|
Map<String, String> c9 = featureOriginUser.getOrDefault("alg_mid_feature_returncf", new HashMap<>());
|
|
|
|
|
@@ -166,21 +175,21 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
|
|
|
for (RankItem item : rankItems) {
|
|
|
Map<String, Double> featureMap = new HashMap<>();
|
|
|
String vid = item.getVideoId() + "";
|
|
|
- Map<String, String> b1 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_all_exp", new HashMap<>());
|
|
|
+ Map<String, String> b1 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_all_exp_v2", new HashMap<>());
|
|
|
Map<String, String> b2 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_all_share", new HashMap<>());
|
|
|
Map<String, String> b3 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_all_return", new HashMap<>());
|
|
|
- Map<String, String> b6 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_exp2share", new HashMap<>());
|
|
|
+ Map<String, String> b6 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_exp2share_v2", new HashMap<>());
|
|
|
Map<String, String> b7 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_share2return", new HashMap<>());
|
|
|
|
|
|
- Map<String, String> b8 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_noflow_exp", new HashMap<>());
|
|
|
- Map<String, String> b9 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_noflow_root_share", new HashMap<>());
|
|
|
- Map<String, String> b10 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_noflow_root_return", new HashMap<>());
|
|
|
- Map<String, String> b11 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_flow_exp", new HashMap<>());
|
|
|
- Map<String, String> b12 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_flow_root_share", new HashMap<>());
|
|
|
- Map<String, String> b13 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_flow_root_return", new HashMap<>());
|
|
|
- Map<String, String> b17 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_province_exp", new HashMap<>());
|
|
|
- Map<String, String> b18 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_province_root_share", new HashMap<>());
|
|
|
- Map<String, String> b19 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_province_root_return", new HashMap<>());
|
|
|
+ Map<String, String> b8 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_noflow_exp_v2", new HashMap<>());
|
|
|
+ Map<String, String> b9 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_noflow_root_share_v2", new HashMap<>());
|
|
|
+ Map<String, String> b10 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_noflow_root_return_v2", new HashMap<>());
|
|
|
+ Map<String, String> b11 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_flow_exp_v2", new HashMap<>());
|
|
|
+ Map<String, String> b12 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_flow_root_share_v2", new HashMap<>());
|
|
|
+ Map<String, String> b13 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_flow_root_return_v2", new HashMap<>());
|
|
|
+ Map<String, String> b17 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_province_exp_v2", new HashMap<>());
|
|
|
+ Map<String, String> b18 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_province_root_share_v2", new HashMap<>());
|
|
|
+ Map<String, String> b19 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_vid_feature_feed_province_root_return_v2", new HashMap<>());
|
|
|
|
|
|
List<Tuple4> originData = Arrays.asList(
|
|
|
new Tuple4(b1, b2, b3, "b123"),
|
|
@@ -201,21 +210,18 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
|
|
|
double f3 = ExtractorUtils.calDiv(returns, exp);
|
|
|
double f4 = ExtractorUtils.calLog(returns);
|
|
|
double f5 = f3 * f4;
|
|
|
- double f6 = ExtractorUtils.calDiv(returns, share);
|
|
|
|
|
|
String key1 = tuple4.name + "_" + prefix2 + "_" + "STR";
|
|
|
String key2 = tuple4.name + "_" + prefix2 + "_" + "log(share)";
|
|
|
String key3 = tuple4.name + "_" + prefix2 + "_" + "ROV";
|
|
|
String key4 = tuple4.name + "_" + prefix2 + "_" + "log(return)";
|
|
|
String key5 = tuple4.name + "_" + prefix2 + "_" + "ROV*log(return)";
|
|
|
- String key6 = tuple4.name + "_" + prefix2 + "_" + "ROS";
|
|
|
|
|
|
featureMap.put(key1, f1);
|
|
|
featureMap.put(key2, f2);
|
|
|
featureMap.put(key3, f3);
|
|
|
featureMap.put(key4, f4);
|
|
|
featureMap.put(key5, f5);
|
|
|
- featureMap.put(key6, f6);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -225,14 +231,51 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
|
|
|
|
|
|
String title = videoInfo.getOrDefault("title", "");
|
|
|
if (!title.isEmpty()) {
|
|
|
- for (String name : Arrays.asList("c3_feature", "c4_feature", "c5_feature", "c6_feature", "c7_feature")) {
|
|
|
- for (String key_time : Arrays.asList("tags_1d", "tags_3d", "tags_7d")) {
|
|
|
- String tags = c34567Map.getOrDefault(name + "_" + key_time, "");
|
|
|
- if (!tags.isEmpty()) {
|
|
|
- Double[] doubles = ExtractorUtils.funcC34567ForTags(tags, title);
|
|
|
- featureMap.put(name + "_" + key_time + "_matchnum", doubles[0]);
|
|
|
- featureMap.put(name + "_" + key_time + "_maxscore", doubles[1]);
|
|
|
- featureMap.put(name + "_" + key_time + "_avgscore", doubles[2]);
|
|
|
+ if (similarityConcurrent) {
|
|
|
+ List<Future<Pair<String, Double[]>>> futures = new ArrayList<>();
|
|
|
+ for (String name : Arrays.asList("c3_feature", "c4_feature", "c5_feature", "c6_feature", "c7_feature")) {
|
|
|
+ for (String key_time : Arrays.asList("tags_1d", "tags_3d", "tags_7d")) {
|
|
|
+ String key = name + "_" + key_time;
|
|
|
+ String tags = c34567Map.getOrDefault(key, "");
|
|
|
+ if (!tags.isEmpty()) {
|
|
|
+ Future<Pair<String, Double[]>> future = ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
+ Double[] doubles = null;
|
|
|
+ if (param.getAbExpCodes().contains(word2vecExp)) {
|
|
|
+ doubles = ExtractorUtils.funcC34567ForTagsNew(tags, title);
|
|
|
+ } else {
|
|
|
+ doubles = ExtractorUtils.funcC34567ForTags(tags, title);
|
|
|
+ }
|
|
|
+ return Pair.create(key, doubles);
|
|
|
+ });
|
|
|
+ futures.add(future);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ for (Future<Pair<String, Double[]>> future : futures) {
|
|
|
+ Pair<String, Double[]> pair = future.get(1000, TimeUnit.MILLISECONDS);
|
|
|
+ featureMap.put(pair.getFirst() + "_matchnum", pair.getSecond()[0]);
|
|
|
+ featureMap.put(pair.getFirst() + "_maxscore", pair.getSecond()[1]);
|
|
|
+ featureMap.put(pair.getFirst() + "_avgscore", pair.getSecond()[2]);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("concurrent similarity error", e);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (String name : Arrays.asList("c3_feature", "c4_feature", "c5_feature", "c6_feature", "c7_feature")) {
|
|
|
+ for (String key_time : Arrays.asList("tags_1d", "tags_3d", "tags_7d")) {
|
|
|
+ String tags = c34567Map.getOrDefault(name + "_" + key_time, "");
|
|
|
+ if (!tags.isEmpty()) {
|
|
|
+ Double[] doubles = null;
|
|
|
+ if (param.getAbExpCodes().contains(word2vecExp)) {
|
|
|
+ doubles = ExtractorUtils.funcC34567ForTagsNew(tags, title);
|
|
|
+ } else {
|
|
|
+ doubles = ExtractorUtils.funcC34567ForTags(tags, title);
|
|
|
+ }
|
|
|
+ featureMap.put(name + "_" + key_time + "_matchnum", doubles[0]);
|
|
|
+ featureMap.put(name + "_" + key_time + "_maxscore", doubles[1]);
|
|
|
+ featureMap.put(name + "_" + key_time + "_avgscore", doubles[2]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -254,7 +297,7 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Map<String, String> d1 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_recsys_feature_cf_i2i_new", new HashMap<>());
|
|
|
+ Map<String, String> d1 = featureOriginVideo.getOrDefault(vid, new HashMap<>()).getOrDefault("alg_recsys_feature_cf_i2i_new_v2", new HashMap<>());
|
|
|
if (!d1.isEmpty()) {
|
|
|
featureMap.put("d1_exp", Double.parseDouble(d1.getOrDefault("exp", "0")));
|
|
|
featureMap.put("d1_return_n", Double.parseDouble(d1.getOrDefault("return_n", "0")));
|
|
@@ -296,33 +339,57 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
|
|
|
item.featureMap = featureMap;
|
|
|
}
|
|
|
|
|
|
- // TODO 3 排序
|
|
|
- Map<String, String> sceneFeatureMap = new HashMap<>(0);
|
|
|
|
|
|
- List<RankItem> items = ScorerUtils.getScorerPipeline("feeds_score_config_20240711.conf")
|
|
|
- .scoring(sceneFeatureMap, userFeatureMap, rankItems);
|
|
|
- String redisScoreKey = mergeWeight.getOrDefault("redisScoreKey", 0.0) < 0.5 ? "redis:vid_hasreturn_rov:" : "redis:vid_hasreturn_rov_7d:";
|
|
|
- Map<String, Map<String, String>> vid2MapFeature = this.getVideoRedisFeature(vids, redisScoreKey);
|
|
|
- List<Video> result = new ArrayList<>();
|
|
|
- String hasReturnRovKey = mergeWeight.getOrDefault("hasReturnRovKey", 1.0) < 0.5 ? "rate_1" : "rate_n";
|
|
|
- Double chooseFunction = mergeWeight.getOrDefault("chooseFunction", 0.0);
|
|
|
- Double rosDefault = mergeWeight.getOrDefault("rosDefault", 1.0);
|
|
|
+ // 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);
|
|
|
+
|
|
|
+ // 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);
|
|
|
+ List<Video> result = new ArrayList<>();
|
|
|
for (RankItem item : items) {
|
|
|
+ item.getScoresMap().put("alpha_vov", alpha_vov);
|
|
|
double score = 0.0;
|
|
|
- double hasReturnRovScore = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>())
|
|
|
- .getOrDefault(hasReturnRovKey, "0"));
|
|
|
- item.getScoresMap().put("hasReturnRovScore", hasReturnRovScore);
|
|
|
- double fmRov = item.getScoreRov();
|
|
|
+ double fmRovOrigin = item.getScoreRov();
|
|
|
+ item.getScoresMap().put("fmRovOrigin", fmRovOrigin);
|
|
|
+ double fmRov = restoreScore(fmRovOrigin);
|
|
|
item.getScoresMap().put("fmRov", fmRov);
|
|
|
- if (chooseFunction == 0){
|
|
|
- score = fmRov * (rosDefault + hasReturnRovScore);
|
|
|
- }else if (chooseFunction == 1){
|
|
|
- score = fmRov * (1 + Math.log(hasReturnRovScore + 1));
|
|
|
- }else {
|
|
|
- score = fmRov * (1 + hasReturnRovScore);
|
|
|
+ double hasReturnRovScore = Double.parseDouble(vid2MapFeature.getOrDefault(item.getVideoId() + "", new HashMap<>()).getOrDefault("rate_n", "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);
|
|
|
+
|
|
|
Video video = item.getVideo();
|
|
|
video.setScore(score);
|
|
|
video.setSortScore(score);
|
|
@@ -340,85 +407,6 @@ public class RankStrategy4RegionMergeModelV564 extends RankStrategy4RegionMergeM
|
|
|
result.add(video);
|
|
|
}
|
|
|
result.sort(Comparator.comparingDouble(o -> -o.getSortScore()));
|
|
|
-
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
- private Map<String, Map<String, String>> extractVideoFeature(Map<String, Map<String, Map<String, String>>> featureMap) {
|
|
|
- // TODO
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- private Map<String, String> extractSceneFeature(Map<String, Map<String, Map<String, String>>> featureMap) {
|
|
|
- // TODO
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- private Map<String, String> extractUserFeature(Map<String, Map<String, Map<String, String>>> featureMap) {
|
|
|
- // TODO
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- public void readBucketFile() {
|
|
|
- InputStream resourceStream = RankStrategy4RegionMergeModelV564.class.getClassLoader().getResourceAsStream("20240609_bucket_314.txt");
|
|
|
- if (resourceStream != null) {
|
|
|
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceStream))) {
|
|
|
- Map<String, double[]> bucketsMap = new HashMap<>();
|
|
|
- Map<String, Double> bucketsLen = new HashMap<>();
|
|
|
- String line;
|
|
|
- while ((line = reader.readLine()) != null) {
|
|
|
- // 替换空格和换行符,过滤空行
|
|
|
- line = line.replace(" ", "").replaceAll("\n", "");
|
|
|
- if (!line.isEmpty()) {
|
|
|
- String[] rList = line.split("\t");
|
|
|
- if (rList.length == 3) {
|
|
|
- String key = rList[0];
|
|
|
- double value1 = Double.parseDouble(rList[1]);
|
|
|
- bucketsLen.put(key, value1);
|
|
|
- double[] value2 = Arrays.stream(rList[2].split(","))
|
|
|
- .mapToDouble(Double::valueOf)
|
|
|
- .toArray();
|
|
|
- bucketsMap.put(key, value2);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- this.bucketsMap = bucketsMap;
|
|
|
- this.bucketsLen = bucketsLen;
|
|
|
- } catch (IOException e) {
|
|
|
- log.error("something is wrong in parse bucket file:" + e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("no bucket file");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- static class Tuple4 {
|
|
|
- public Map<String, String> first;
|
|
|
- public Map<String, String> second;
|
|
|
- public Map<String, String> third;
|
|
|
-
|
|
|
- public String name;
|
|
|
-
|
|
|
- public Tuple4(Map<String, String> first, Map<String, String> second, Map<String, String> third, String name) {
|
|
|
- this.first = first;
|
|
|
- this.second = second;
|
|
|
- this.third = third;
|
|
|
- this.name = name;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- static class Tuple2 {
|
|
|
- public Map<String, String> first;
|
|
|
-
|
|
|
- public String name;
|
|
|
-
|
|
|
- public Tuple2(Map<String, String> first, String name) {
|
|
|
- this.first = first;
|
|
|
- this.name = name;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|