|
@@ -3,10 +3,8 @@ package com.tzld.piaoquan.recommend.server.service.rank.strategy;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
|
-import com.tzld.piaoquan.recommend.feature.domain.video.base.UserFeature;
|
|
|
import com.tzld.piaoquan.recommend.server.common.base.RankItem;
|
|
|
import com.tzld.piaoquan.recommend.server.model.Video;
|
|
|
-import com.tzld.piaoquan.recommend.server.service.flowpool.FlowPoolConstants;
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.RankParam;
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.RankResult;
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.RankService;
|
|
@@ -18,9 +16,7 @@ import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorBo
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorDensity;
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorInsert;
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.processor.RankProcessorTagFilter;
|
|
|
-import com.tzld.piaoquan.recommend.server.service.recall.RecallResult;
|
|
|
import com.tzld.piaoquan.recommend.server.service.recall.strategy.*;
|
|
|
-import com.tzld.piaoquan.recommend.server.service.score.ScoreParam;
|
|
|
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;
|
|
@@ -48,23 +44,24 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
@ApolloJsonValue("${rank.score.merge.weightv548:}")
|
|
|
private Map<String, Double> mergeWeight;
|
|
|
@ApolloJsonValue("${RankStrategy4DensityFilterV2:}")
|
|
|
- private Map<String,Map<String, Map<String, String>>> filterRules = new HashMap<>();
|
|
|
+ private Map<String, Map<String, Map<String, String>>> filterRules = new HashMap<>();
|
|
|
final private String CLASS_NAME = this.getClass().getSimpleName();
|
|
|
|
|
|
- public void duplicate(Set<Long> setVideo, List<Video> videos){
|
|
|
+ public void duplicate(Set<Long> setVideo, List<Video> videos) {
|
|
|
Iterator<Video> iterator = videos.iterator();
|
|
|
- while(iterator.hasNext()){
|
|
|
+ while (iterator.hasNext()) {
|
|
|
Video v = iterator.next();
|
|
|
- if (setVideo.contains(v.getVideoId())){
|
|
|
+ if (setVideo.contains(v.getVideoId())) {
|
|
|
iterator.remove();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
setVideo.add(v.getVideoId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public List<Video> mergeAndRankRovRecall(RankParam param) {
|
|
|
- Map<String, Double> mergeWeight = this.mergeWeight != null? this.mergeWeight: new HashMap<>(0);
|
|
|
+ Map<String, Double> mergeWeight = this.mergeWeight != null ? this.mergeWeight : new HashMap<>(0);
|
|
|
//-------------------融-------------------
|
|
|
//-------------------合-------------------
|
|
|
//-------------------逻-------------------
|
|
@@ -113,8 +110,6 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
rovRecallRank.addAll(v7.subList(0, Math.min(mergeWeight.getOrDefault("v7", 10.0).intValue(), v7.size())));
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//-------------------排-------------------
|
|
|
//-------------------序-------------------
|
|
|
//-------------------逻-------------------
|
|
@@ -129,19 +124,19 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
String date = new SimpleDateFormat("yyyyMMdd").format(calendar.getTime());
|
|
|
String hour = new SimpleDateFormat("HH").format(calendar.getTime());
|
|
|
String rtFeaPart1h = date + hour;
|
|
|
- if (rtFeaPartKeyResult != null){
|
|
|
- if (rtFeaPartKeyResult.get(1) != null){
|
|
|
+ if (rtFeaPartKeyResult != null) {
|
|
|
+ if (rtFeaPartKeyResult.get(1) != null) {
|
|
|
rtFeaPart1h = rtFeaPartKeyResult.get(1);
|
|
|
}
|
|
|
}
|
|
|
// 2 统计分
|
|
|
String cur = rtFeaPart1h;
|
|
|
List<String> datehours = new LinkedList<>(); // 时间是倒叙的
|
|
|
- for (int i=0; i<24; ++i){
|
|
|
+ for (int i = 0; i < 24; ++i) {
|
|
|
datehours.add(cur);
|
|
|
cur = ExtractorUtils.subtractHours(cur, 1);
|
|
|
}
|
|
|
- for (RankItem item : items){
|
|
|
+ for (RankItem item : items) {
|
|
|
Map<String, String> itemBasicMap = item.getItemBasicFeature();
|
|
|
Map<String, Map<String, Double>> itemRealMap = item.getItemRealTimeFeature();
|
|
|
List<Double> views = getStaticData(itemRealMap, datehours, "view_pv_list_1h");
|
|
@@ -199,10 +194,10 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
double g = mergeWeight.getOrDefault("g", 2.0);
|
|
|
double h = mergeWeight.getOrDefault("h", 240.0);
|
|
|
double ifAdd = mergeWeight.getOrDefault("ifAdd", 1.0);
|
|
|
- for (RankItem item : items){
|
|
|
- double trendScore = item.scoresMap.getOrDefault("trendScore", 0.0) > 1E-8 ?
|
|
|
+ for (RankItem item : items) {
|
|
|
+ double trendScore = item.scoresMap.getOrDefault("trendScore", 0.0) > 1E-8 ?
|
|
|
item.scoresMap.getOrDefault("trendScore", 0.0) : 0.0;
|
|
|
- double newVideoScore = item.scoresMap.getOrDefault("newVideoScore", 0.0) > 1E-8 ?
|
|
|
+ double newVideoScore = item.scoresMap.getOrDefault("newVideoScore", 0.0) > 1E-8 ?
|
|
|
item.scoresMap.getOrDefault("newVideoScore", 0.0) : 0.0;
|
|
|
double strScore = item.getScoreStr();
|
|
|
double rosScore = item.scoresMap.getOrDefault("share2returnScore", 0.0);
|
|
@@ -210,16 +205,16 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
double view2allreturnScore = item.scoresMap.getOrDefault("view2allreturnScore", 0.0);
|
|
|
double preturnsScore = Math.log(1 + item.scoresMap.getOrDefault("preturnsScore", 0.0));
|
|
|
double score = 0.0;
|
|
|
- if (ifAdd < 0.5){
|
|
|
+ if (ifAdd < 0.5) {
|
|
|
score = Math.pow(strScore, a) * Math.pow(rosScore, b) + c * preturnsScore +
|
|
|
- (newVideoScore > 1E-8? d * trendScore * (e + newVideoScore): 0.0);
|
|
|
- }else {
|
|
|
+ (newVideoScore > 1E-8 ? d * trendScore * (e + newVideoScore) : 0.0);
|
|
|
+ } else {
|
|
|
score = a * strScore + b * rosScore + c * preturnsScore +
|
|
|
- (newVideoScore > 1E-8? d * trendScore * (e + newVideoScore): 0.0);
|
|
|
+ (newVideoScore > 1E-8 ? d * trendScore * (e + newVideoScore) : 0.0);
|
|
|
|
|
|
}
|
|
|
double allreturnsScore = item.scoresMap.getOrDefault("allreturnsScore", 0.0);
|
|
|
- if (allreturnsScore > h){
|
|
|
+ if (allreturnsScore > h) {
|
|
|
score += (f * share2allreturnScore + g * view2allreturnScore);
|
|
|
}
|
|
|
Video video = item.getVideo();
|
|
@@ -232,46 +227,50 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
Collections.sort(result, Comparator.comparingDouble(o -> -o.getSortScore()));
|
|
|
return result;
|
|
|
}
|
|
|
- public double calNewVideoScore(Map<String, String> itemBasicMap){
|
|
|
+
|
|
|
+ public double calNewVideoScore(Map<String, String> itemBasicMap) {
|
|
|
double existenceDays = Double.valueOf(itemBasicMap.getOrDefault("existence_days", "30"));
|
|
|
- if (existenceDays > 5){
|
|
|
+ if (existenceDays > 5) {
|
|
|
return 0.0;
|
|
|
}
|
|
|
double score = 1.0 / (existenceDays + 10.0);
|
|
|
return score;
|
|
|
}
|
|
|
- public double calTrendScore(List<Double> data){
|
|
|
+
|
|
|
+ public double calTrendScore(List<Double> data) {
|
|
|
double sum = 0.0;
|
|
|
int size = data.size();
|
|
|
- for (int i=0; i<size-4; ++i){
|
|
|
- sum += data.get(i) - data.get(i+4);
|
|
|
+ for (int i = 0; i < size - 4; ++i) {
|
|
|
+ sum += data.get(i) - data.get(i + 4);
|
|
|
}
|
|
|
- if (sum * 10 > 0.6){
|
|
|
+ if (sum * 10 > 0.6) {
|
|
|
sum = 0.6;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sum = sum * 10;
|
|
|
}
|
|
|
- if (sum > 0){
|
|
|
+ if (sum > 0) {
|
|
|
// 为了打断点
|
|
|
sum = sum;
|
|
|
}
|
|
|
return sum;
|
|
|
}
|
|
|
- public Double calScoreWeight(List<Double> data){
|
|
|
+
|
|
|
+ public Double calScoreWeight(List<Double> data) {
|
|
|
Double up = 0.0;
|
|
|
Double down = 0.0;
|
|
|
- for (int i=0; i<data.size(); ++i){
|
|
|
+ for (int i = 0; i < data.size(); ++i) {
|
|
|
up += 1.0 / (i + 1) * data.get(i);
|
|
|
down += 1.0 / (i + 1);
|
|
|
}
|
|
|
- return down > 1E-8? up / down: 0.0;
|
|
|
+ return down > 1E-8 ? up / down : 0.0;
|
|
|
}
|
|
|
- public List<Double> getRateData(List<Double> ups, List<Double> downs, Double up, Double down){
|
|
|
+
|
|
|
+ public List<Double> getRateData(List<Double> ups, List<Double> downs, Double up, Double down) {
|
|
|
List<Double> data = new LinkedList<>();
|
|
|
- for(int i=0; i<ups.size(); ++i){
|
|
|
- if (ExtractorUtils.isDoubleEqualToZero(downs.get(i) + down)){
|
|
|
+ for (int i = 0; i < ups.size(); ++i) {
|
|
|
+ if (ExtractorUtils.isDoubleEqualToZero(downs.get(i) + down)) {
|
|
|
data.add(0.0);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
data.add(
|
|
|
(ups.get(i) + up) / (downs.get(i) + down)
|
|
|
);
|
|
@@ -279,21 +278,23 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
}
|
|
|
return data;
|
|
|
}
|
|
|
+
|
|
|
public List<Double> getStaticData(Map<String, Map<String, Double>> itemRealMap,
|
|
|
- List<String> datehours, String key){
|
|
|
+ List<String> datehours, String key) {
|
|
|
List<Double> views = new LinkedList<>();
|
|
|
Map<String, Double> tmp = itemRealMap.getOrDefault(key, new HashMap<>());
|
|
|
- for (String dh : datehours){
|
|
|
+ for (String dh : datehours) {
|
|
|
views.add(tmp.getOrDefault(dh, 0.0D) +
|
|
|
- (views.isEmpty() ? 0.0: views.get(views.size()-1))
|
|
|
+ (views.isEmpty() ? 0.0 : views.get(views.size() - 1))
|
|
|
);
|
|
|
}
|
|
|
return views;
|
|
|
}
|
|
|
+
|
|
|
public List<RankItem> model(List<Video> videos, RankParam param,
|
|
|
- List<String> rtFeaPart){
|
|
|
+ List<String> rtFeaPart) {
|
|
|
List<RankItem> result = new ArrayList<>();
|
|
|
- if (videos.isEmpty()){
|
|
|
+ if (videos.isEmpty()) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -308,27 +309,22 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
redisTemplate.afterPropertiesSet();
|
|
|
|
|
|
// 0: 场景特征处理
|
|
|
- Map<String, String> sceneFeatureMap = this.getSceneFeature(param);
|
|
|
+ Map<String, String> sceneFeatureMap = this.getSceneFeature(param);
|
|
|
|
|
|
// 1: user特征处理
|
|
|
Map<String, String> userFeatureMap = new HashMap<>();
|
|
|
- if (param.getMid() != null && !param.getMid().isEmpty()){
|
|
|
+ if (param.getMid() != null && !param.getMid().isEmpty()) {
|
|
|
String midKey = "user_info_4video_" + param.getMid();
|
|
|
String userFeatureStr = redisTemplate.opsForValue().get(midKey);
|
|
|
- if (userFeatureStr != null){
|
|
|
- try{
|
|
|
+ if (userFeatureStr != null) {
|
|
|
+ try {
|
|
|
userFeatureMap = JSONUtils.fromJson(userFeatureStr,
|
|
|
- new TypeToken<Map<String, String>>() {},
|
|
|
+ new TypeToken<Map<String, String>>() {
|
|
|
+ },
|
|
|
userFeatureMap);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error(String.format("parse user json is wrong in {} with {}", this.CLASS_NAME, e));
|
|
|
}
|
|
|
- }else{
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.put("name", "user_key_in_model_is_null");
|
|
|
- obj.put("class", this.CLASS_NAME);
|
|
|
-// log.info(obj.toString());
|
|
|
-// return videos;
|
|
|
}
|
|
|
}
|
|
|
final Set<String> userFeatureSet = new HashSet<>(Arrays.asList(
|
|
@@ -343,21 +339,6 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
iterator.remove();
|
|
|
}
|
|
|
}
|
|
|
- Map<String, String> f1 = RankExtractorUserFeature.getOriginFeature(userFeatureMap,
|
|
|
- new HashSet<String>(Arrays.asList(
|
|
|
- "machineinfo_brand", "machineinfo_model", "machineinfo_platform", "machineinfo_system"
|
|
|
- ))
|
|
|
- );
|
|
|
- Map<String, String> f2 = RankExtractorUserFeature.getUserRateFeature(userFeatureMap);
|
|
|
- Map<String, String> f3 = RankExtractorUserFeature.cntFeatureChange(userFeatureMap,
|
|
|
- new HashSet<String>(Arrays.asList(
|
|
|
- "u_1day_exp_cnt", "u_1day_click_cnt", "u_1day_share_cnt", "u_1day_return_cnt",
|
|
|
- "u_3day_exp_cnt", "u_3day_click_cnt", "u_3day_share_cnt", "u_3day_return_cnt"
|
|
|
- ))
|
|
|
- );
|
|
|
- f1.putAll(f2);
|
|
|
- f1.putAll(f3);
|
|
|
-// log.info("userFeature in model = {}", JSONUtils.toJson(f1));
|
|
|
|
|
|
// 2-1: item特征处理
|
|
|
final Set<String> itemFeatureSet = new HashSet<>(Arrays.asList(
|
|
@@ -368,18 +349,19 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
|
|
|
List<RankItem> rankItems = CommonCollectionUtils.toList(videos, RankItem::new);
|
|
|
List<Long> videoIds = CommonCollectionUtils.toListDistinct(videos, Video::getVideoId);
|
|
|
- List<String> videoFeatureKeys = videoIds.stream().map(r-> "video_info_" + r)
|
|
|
+ List<String> videoFeatureKeys = videoIds.stream().map(r -> "video_info_" + r)
|
|
|
.collect(Collectors.toList());
|
|
|
List<String> videoFeatures = redisTemplate.opsForValue().multiGet(videoFeatureKeys);
|
|
|
- if (videoFeatures != null){
|
|
|
- for (int i=0; i<videoFeatures.size(); ++i){
|
|
|
+ if (videoFeatures != null) {
|
|
|
+ for (int i = 0; i < videoFeatures.size(); ++i) {
|
|
|
String vF = videoFeatures.get(i);
|
|
|
Map<String, String> vfMap = new HashMap<>();
|
|
|
- if (vF == null){
|
|
|
+ if (vF == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- try{
|
|
|
- vfMap = JSONUtils.fromJson(vF, new TypeToken<Map<String, String>>() {}, vfMap);
|
|
|
+ try {
|
|
|
+ vfMap = JSONUtils.fromJson(vF, new TypeToken<Map<String, String>>() {
|
|
|
+ }, vfMap);
|
|
|
Map<String, String> vfMapCopy = new HashMap<>(vfMap);
|
|
|
rankItems.get(i).setItemBasicFeature(vfMapCopy);
|
|
|
Iterator<Map.Entry<String, String>> iteratorIn = vfMap.entrySet().iterator();
|
|
@@ -398,7 +380,7 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
);
|
|
|
f4.putAll(f5);
|
|
|
rankItems.get(i).setFeatureMap(f4);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error(String.format("parse video json is wrong in {} with {}", this.CLASS_NAME, e));
|
|
|
}
|
|
|
}
|
|
@@ -411,80 +393,82 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
String hour = new SimpleDateFormat("HH").format(calendar.getTime());
|
|
|
String rtFeaPart1day = date + hour;
|
|
|
String rtFeaPart1h = date + hour;
|
|
|
- if (rtFeaPartKeyResult != null){
|
|
|
- if (rtFeaPartKeyResult.get(0) != null){
|
|
|
+ if (rtFeaPartKeyResult != null) {
|
|
|
+ if (rtFeaPartKeyResult.get(0) != null) {
|
|
|
rtFeaPart1day = rtFeaPartKeyResult.get(0);
|
|
|
}
|
|
|
- if (rtFeaPartKeyResult.get(1) != null){
|
|
|
+ if (rtFeaPartKeyResult.get(1) != null) {
|
|
|
rtFeaPart1h = rtFeaPartKeyResult.get(1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<String> videoRtKeys1 = videoIds.stream().map(r-> "item_rt_fea_1day_" + r)
|
|
|
+ List<String> videoRtKeys1 = videoIds.stream().map(r -> "item_rt_fea_1day_" + r)
|
|
|
.collect(Collectors.toList());
|
|
|
- List<String> videoRtKeys2 = videoIds.stream().map(r-> "item_rt_fea_1h_" + r)
|
|
|
+ List<String> videoRtKeys2 = videoIds.stream().map(r -> "item_rt_fea_1h_" + r)
|
|
|
.collect(Collectors.toList());
|
|
|
videoRtKeys1.addAll(videoRtKeys2);
|
|
|
List<String> videoRtFeatures = this.redisTemplate.opsForValue().multiGet(videoRtKeys1);
|
|
|
|
|
|
|
|
|
- if (videoRtFeatures != null){
|
|
|
+ if (videoRtFeatures != null) {
|
|
|
int j = 0;
|
|
|
- for (RankItem item: rankItems){
|
|
|
+ for (RankItem item : rankItems) {
|
|
|
String vF = videoRtFeatures.get(j);
|
|
|
++j;
|
|
|
- if (vF == null){
|
|
|
+ if (vF == null) {
|
|
|
continue;
|
|
|
}
|
|
|
Map<String, String> vfMap = new HashMap<>();
|
|
|
Map<String, Map<String, Double>> vfMapNew = new HashMap<>();
|
|
|
- try{
|
|
|
- vfMap = JSONUtils.fromJson(vF, new TypeToken<Map<String, String>>() {}, vfMap);
|
|
|
- for (Map.Entry<String, String> entry : vfMap.entrySet()){
|
|
|
+ try {
|
|
|
+ vfMap = JSONUtils.fromJson(vF, new TypeToken<Map<String, String>>() {
|
|
|
+ }, vfMap);
|
|
|
+ for (Map.Entry<String, String> entry : vfMap.entrySet()) {
|
|
|
String value = entry.getValue();
|
|
|
- if (value == null){
|
|
|
+ if (value == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- String [] var1 = value.split(",");
|
|
|
+ String[] var1 = value.split(",");
|
|
|
Map<String, Double> tmp = new HashMap<>();
|
|
|
- for (String var2 : var1){
|
|
|
- String [] var3 = var2.split(":");
|
|
|
+ for (String var2 : var1) {
|
|
|
+ String[] var3 = var2.split(":");
|
|
|
tmp.put(var3[0], Double.valueOf(var3[1]));
|
|
|
}
|
|
|
vfMapNew.put(entry.getKey(), tmp);
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error(String.format("parse video item_rt_fea_1day_ json is wrong in {} with {}", this.CLASS_NAME, e));
|
|
|
}
|
|
|
Map<String, String> f8 = RankExtractorItemFeature.getItemRealtimeRate(vfMapNew, rtFeaPart1day);
|
|
|
item.getFeatureMap().putAll(f8);
|
|
|
}
|
|
|
- for (RankItem item: rankItems){
|
|
|
+ for (RankItem item : rankItems) {
|
|
|
String vF = videoRtFeatures.get(j);
|
|
|
++j;
|
|
|
- if (vF == null){
|
|
|
+ if (vF == null) {
|
|
|
continue;
|
|
|
}
|
|
|
Map<String, String> vfMap = new HashMap<>();
|
|
|
Map<String, Map<String, Double>> vfMapNew = new HashMap<>();
|
|
|
- try{
|
|
|
- vfMap = JSONUtils.fromJson(vF, new TypeToken<Map<String, String>>() {}, vfMap);
|
|
|
+ try {
|
|
|
+ vfMap = JSONUtils.fromJson(vF, new TypeToken<Map<String, String>>() {
|
|
|
+ }, vfMap);
|
|
|
|
|
|
- for (Map.Entry<String, String> entry : vfMap.entrySet()){
|
|
|
+ for (Map.Entry<String, String> entry : vfMap.entrySet()) {
|
|
|
String value = entry.getValue();
|
|
|
- if (value == null){
|
|
|
+ if (value == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- String [] var1 = value.split(",");
|
|
|
+ String[] var1 = value.split(",");
|
|
|
Map<String, Double> tmp = new HashMap<>();
|
|
|
- for (String var2 : var1){
|
|
|
- String [] var3 = var2.split(":");
|
|
|
+ for (String var2 : var1) {
|
|
|
+ String[] var3 = var2.split(":");
|
|
|
tmp.put(var3[0], Double.valueOf(var3[1]));
|
|
|
}
|
|
|
vfMapNew.put(entry.getKey(), tmp);
|
|
|
}
|
|
|
item.setItemRealTimeFeature(vfMapNew);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error(String.format("parse video item_rt_fea_1h_ json is wrong in {} with {}", this.CLASS_NAME, e));
|
|
|
}
|
|
|
Map<String, String> f8 = RankExtractorItemFeature.getItemRealtimeRate(vfMapNew, rtFeaPart1h);
|
|
@@ -493,19 +477,12 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// log.info("ItemFeature = {}", JSONUtils.toJson(videoFeatures));
|
|
|
-
|
|
|
-
|
|
|
|
|
|
List<RankItem> rovRecallScore = ScorerUtils.getScorerPipeline(ScorerUtils.BASE_CONF)
|
|
|
.scoring(sceneFeatureMap, userFeatureMap, rankItems);
|
|
|
-// log.info("mergeAndRankRovRecallNew rovRecallScore={}", JSONUtils.toJson(rovRecallScore));
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.put("name", "user_key_in_model_is_not_null");
|
|
|
- obj.put("class", this.CLASS_NAME);
|
|
|
-// log.info(obj.toString());
|
|
|
return rovRecallScore;
|
|
|
}
|
|
|
+
|
|
|
private Map<String, String> getSceneFeature(RankParam param) {
|
|
|
Map<String, String> sceneFeatureMap = new HashMap<>();
|
|
|
String provinceCn = param.getProvince();
|
|
@@ -522,8 +499,8 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
"吉林市".equals(city) |
|
|
|
"新竹市".equals(city) |
|
|
|
"嘉义市".equals(city)
|
|
|
- ){
|
|
|
- }else{
|
|
|
+ ) {
|
|
|
+ } else {
|
|
|
city = city.replaceAll("市$", "");
|
|
|
}
|
|
|
sceneFeatureMap.put("ctx_city", city);
|
|
@@ -534,6 +511,7 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
|
|
|
return sceneFeatureMap;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public RankResult mergeAndSort(RankParam param, List<Video> rovVideos, List<Video> flowVideos) {
|
|
|
|
|
@@ -551,12 +529,12 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
Map<String, Map<String, String>> rulesMap = this.filterRules.getOrDefault(abCode, new HashMap<>(0));
|
|
|
|
|
|
//3 标签读取
|
|
|
- if (rulesMap != null && !rulesMap.isEmpty()){
|
|
|
+ if (rulesMap != null && !rulesMap.isEmpty()) {
|
|
|
RankExtractorItemTags extractorItemTags = new RankExtractorItemTags(this.redisTemplate);
|
|
|
extractorItemTags.processor(rovVideos, flowVideos);
|
|
|
}
|
|
|
//6 合并结果时间卡控
|
|
|
- if (rulesMap != null && !rulesMap.isEmpty()){
|
|
|
+ if (rulesMap != null && !rulesMap.isEmpty()) {
|
|
|
RankProcessorTagFilter.processor(rovVideos, flowVideos, rulesMap);
|
|
|
}
|
|
|
|
|
@@ -576,7 +554,6 @@ public class RankStrategy4RegionMergeModelV548 extends RankService {
|
|
|
int rovPoolIndex = param.getTopK();
|
|
|
for (int i = 0; i < param.getSize() - param.getTopK(); i++) {
|
|
|
double rand = RandomUtils.nextDouble(0, 1);
|
|
|
- log.info("rand={}, flowPoolP={}", rand, flowPoolP);
|
|
|
if (rand < flowPoolP) {
|
|
|
if (flowPoolIndex < flowVideos.size()) {
|
|
|
result.add(flowVideos.get(flowPoolIndex++));
|