|
@@ -118,8 +118,10 @@ public class FestivalRecallScore extends AbstractScorer4Recall {
|
|
|
"00:00~2026-02-16 08:00"));
|
|
|
put("立春", Arrays.asList("2024-02-03 15:00~2024-02-04 20:00", "2025-02-01 00:00~2025-02-03 08:00",
|
|
|
"2026-02-02 00:00~2026-02-04 08:00"));
|
|
|
- put("小年", Arrays.asList("2024-01-29 00:00~2024-02-03 20:00", "2025-01-18 00:00~2025-01-23 08:00", "2026-02-06 " +
|
|
|
- "00:00~2026-02-11 08:00"));
|
|
|
+ put("北小年", Arrays.asList("2024-01-29 00:00~2024-02-02 20:00", "2025-01-18 00:00~2025-01-22 10:00", "2026-02-06 " +
|
|
|
+ "00:00~2026-02-10 10:00"));
|
|
|
+ put("南小年", Arrays.asList("2024-01-30 00:00~2024-02-03 20:00", "2025-01-19 00:00~2025-01-23 10:00", "2026-02-07 " +
|
|
|
+ "00:00~2026-02-11 10:00"));
|
|
|
put("大寒", Arrays.asList("2024-01-18 00:00~2024-01-20 08:00", "2025-01-18 00:00~2025-01-20 08:00", "2026-01-18 " +
|
|
|
"00:00~2026-01-20 08:00"));
|
|
|
put("腊八节", Arrays.asList("2024-01-13 00:00~2024-01-18 08:00", "2025-01-02 00:00~2025-01-07 08:00", "2026-01-21 " +
|
|
@@ -139,9 +141,20 @@ public class FestivalRecallScore extends AbstractScorer4Recall {
|
|
|
public void loadModel() {
|
|
|
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) {
|
|
@@ -153,6 +166,15 @@ public class FestivalRecallScore extends AbstractScorer4Recall {
|
|
|
for (Map.Entry<String, List<String>> entry : YEARLY_FESTIVAL_TIME_MAP.entrySet()) {
|
|
|
String festival = entry.getKey();
|
|
|
List<String> timeRangeList = entry.getValue();
|
|
|
+ if (festival.contains("小年")){
|
|
|
+ if ("北小年".contains(festival) && !ifNorth){
|
|
|
+ continue;
|
|
|
+ } else if ("南小年".contains(festival) && ifNorth) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ festival = "小年";
|
|
|
+ }
|
|
|
+
|
|
|
if (isFestivalTime(now, timeRangeList)) {
|
|
|
Pair<LocalDateTime, LocalDateTime> startTimeAndEndTime = getStartTimeAndEndTime(timeRangeList.get(0));
|
|
|
if (startTimeAndEndTime == null) {
|
|
@@ -161,7 +183,6 @@ public class FestivalRecallScore extends AbstractScorer4Recall {
|
|
|
// 节日峰值设置为结束时间的当天的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;
|