Kaynağa Gözat

MOD: 召回去掉正态分布提权

sunxy 1 yıl önce
ebeveyn
işleme
bd86305e00

+ 6 - 19
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/score4recall/strategy/BlessRecallScore.java

@@ -26,19 +26,8 @@ public class BlessRecallScore extends AbstractScorer4Recall {
         doLoadModel(Model4RecallKeyValue.class);
     }
 
-    final Set<String> NORTHERN_PROVINCES = new HashSet<>(Arrays.asList(
-            "北京", "天津", "河北", "山西", "内蒙古"
-            , "辽宁", "吉林", "黑龙江", "山东", "河南", "陕西", "甘肃", "宁夏", "新疆"
-    ));
-
-
     @Override
     public List<Pair<Long, Double>> recall(Map<String, String> params) {
-        // 1 获取省份,判断南北 小年
-        String key = params.getOrDefault("region_province", "中国");
-        boolean ifNorth = NORTHERN_PROVINCES.contains(key);
-
-
         // 节假日、时效性,判断
         Model4RecallKeyValue model = (Model4RecallKeyValue) this.getModel();
         if (model == null || model.kv == null) {
@@ -48,17 +37,12 @@ public class BlessRecallScore extends AbstractScorer4Recall {
         // 节日祝福-每年
         List<Pair<Long, Double>> yearResult = new ArrayList<>();
         String yearlyFestivalTimeRange = params.get("yearly_festival_time_range");
+        if (StringUtils.isBlank(yearlyFestivalTimeRange)) {
+            return new ArrayList<>();
+        }
         JSONObject jsonObject = JSONObject.parseObject(yearlyFestivalTimeRange);
         for (String festival : jsonObject.keySet()) {
             try {
-                if (festival.contains("小年")) {
-                    if ("北小年".contains(festival) && !ifNorth) {
-                        continue;
-                    } else if ("南小年".contains(festival) && ifNorth) {
-                        continue;
-                    }
-                    festival = "小年";
-                }
                 JSONArray jsonArray = jsonObject.getJSONArray(festival);
                 if (jsonArray == null) {
                     continue;
@@ -88,6 +72,9 @@ public class BlessRecallScore extends AbstractScorer4Recall {
         List<Pair<Long, Double>> dayResult = new ArrayList<>();
         // 每日祝福-每天固定时间段
         String dailyFestivalTimeRange = params.get("daily_bless_time_range");
+        if (StringUtils.isBlank(dailyFestivalTimeRange)) {
+            return new ArrayList<>();
+        }
         JSONObject dailyFestivalTimeRangeJson = JSONObject.parseObject(dailyFestivalTimeRange);
         for (String bless : dailyFestivalTimeRangeJson.keySet()) {
             try {

+ 3 - 2
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/score4recall/strategy/FestivalRecallScore.java

@@ -29,8 +29,6 @@ public class FestivalRecallScore extends AbstractScorer4Recall {
             ,"辽宁","吉林","黑龙江","山东","河南","陕西","甘肃","宁夏","新疆"
     ));
 
-
-
     @Override
     public List<Pair<Long, Double>> recall(Map<String, String> params) {
         // 1 获取省份,判断南北 小年
@@ -46,6 +44,9 @@ public class FestivalRecallScore extends AbstractScorer4Recall {
         // 节日祝福-每年
 
         String yearlyFestivalTimeRange = params.get("yearly_festival_time_range");
+        if (StringUtils.isBlank(yearlyFestivalTimeRange)) {
+            return new ArrayList<>();
+        }
         JSONObject jsonObject = JSONObject.parseObject(yearlyFestivalTimeRange);
         List<List<Pair<Long, Double>>> yearResultList = new ArrayList<>();
         for (String festival : jsonObject.keySet()) {