|
@@ -5,13 +5,13 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tzld.piaoquan.recommend.server.service.score.ScorerConfigInfo;
|
|
|
import com.tzld.piaoquan.recommend.server.service.score4recall.AbstractScorer4Recall;
|
|
|
import com.tzld.piaoquan.recommend.server.service.score4recall.model4recall.Model4RecallKeyValue;
|
|
|
+import com.tzld.piaoquan.recommend.server.util.ListMerger;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
public class FestivalRecallScore extends AbstractScorer4Recall {
|
|
@@ -34,9 +34,8 @@ public class FestivalRecallScore extends AbstractScorer4Recall {
|
|
|
@Override
|
|
|
public List<Pair<Long, Double>> recall(Map<String, String> params) {
|
|
|
// 1 获取省份,判断南北 小年
|
|
|
- String key = params.getOrDefault("region_province", "中国");
|
|
|
- boolean ifNorth = NORTHERN_PROVINCES.contains(key);
|
|
|
-
|
|
|
+// String key = params.getOrDefault("region_province", "中国");
|
|
|
+// boolean ifNorth = NORTHERN_PROVINCES.contains(key);
|
|
|
|
|
|
// 节假日、时效性,判断
|
|
|
Model4RecallKeyValue model = (Model4RecallKeyValue) this.getModel();
|
|
@@ -48,7 +47,7 @@ public class FestivalRecallScore extends AbstractScorer4Recall {
|
|
|
|
|
|
String yearlyFestivalTimeRange = params.get("yearly_festival_time_range");
|
|
|
JSONObject jsonObject = JSONObject.parseObject(yearlyFestivalTimeRange);
|
|
|
- List<Pair<Long, Double>> yearResult = new ArrayList<>();
|
|
|
+ List<List<Pair<Long, Double>>> yearResultList = new ArrayList<>();
|
|
|
for (String festival : jsonObject.keySet()) {
|
|
|
try {
|
|
|
// if (festival.contains("小年")) {
|
|
@@ -70,22 +69,19 @@ public class FestivalRecallScore extends AbstractScorer4Recall {
|
|
|
continue;
|
|
|
}
|
|
|
// 节日峰值设置为结束时间的当天的7点
|
|
|
- double weight = DynamicGaussianFunction.calculateValue(LocalDateTime.now(), startTimeAndEndTime.getLeft(),
|
|
|
- startTimeAndEndTime.getRight(), startTimeAndEndTime.getRight().withHour(7));
|
|
|
+// double weight = DynamicGaussianFunction.calculateValue(LocalDateTime.now(), startTimeAndEndTime.getLeft(),
|
|
|
+// startTimeAndEndTime.getRight(), startTimeAndEndTime.getRight().withHour(7));
|
|
|
List<Pair<Long, Double>> festivalLists = model.kv.getOrDefault(festival, new ArrayList<>());
|
|
|
if (festivalLists.isEmpty()) {
|
|
|
continue;
|
|
|
}
|
|
|
- festivalLists = festivalLists.stream().map(pair -> Pair.of(pair.getLeft(), weight))
|
|
|
- .limit(Math.min(50, festivalLists.size()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- yearResult.addAll(festivalLists);
|
|
|
+ yearResultList.add(festivalLists);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- return yearResult;
|
|
|
+ return ListMerger.mergeLists(yearResultList);
|
|
|
}
|
|
|
|
|
|
public Pair<LocalDateTime, LocalDateTime> getStartTimeAndEndTime(String timeRangeList) {
|