Jelajahi Sumber

feat:修改召回

zhaohaipeng 1 Minggu lalu
induk
melakukan
7bf751ee33

+ 4 - 3
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/recall/strategy/YearReturnCate2RecallStrategy.java

@@ -54,7 +54,8 @@ public class YearReturnCate2RecallStrategy implements RecallStrategy {
             if (CollectionUtils.isEmpty(userNetworkVideoCate2)) {
                 return videosResult;
             }
-            List<String> lastTopNCate = userNetworkVideoCate2.subList(0, 3).stream()
+            int limit = Math.min(userNetworkVideoCate2.size(), 3);
+            List<String> lastTopNCate = userNetworkVideoCate2.subList(0, limit).stream()
                     .map(Pair::getValue)
                     .distinct()
                     .collect(Collectors.toList());
@@ -64,7 +65,7 @@ public class YearReturnCate2RecallStrategy implements RecallStrategy {
                     .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet()
                     .stream()
                     .sorted(Map.Entry.<String, Long>comparingByValue().reversed())
-                    .limit(3)
+                    .limit(limit)
                     .map(Map.Entry::getKey)
                     .collect(Collectors.toList());
 
@@ -97,7 +98,7 @@ public class YearReturnCate2RecallStrategy implements RecallStrategy {
         for (int i = 0; i < actVidSeq.size(); i++) {
             long videoIdL = Long.parseLong(actVidSeq.get(i));
             String type = actTypeSeq.get(i);
-            if (!"share".equals(type)) {
+            if (!"click".equals(type)) {
                 continue;
             }
 

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

@@ -54,7 +54,8 @@ public class YearShareCate1RecallStrategy implements RecallStrategy {
             if (CollectionUtils.isEmpty(userNetworkVideoCate1)) {
                 return videosResult;
             }
-            List<String> lastTopNCate = userNetworkVideoCate1.subList(0, 3).stream()
+            int limit = Math.min(userNetworkVideoCate1.size(), 3);
+            List<String> lastTopNCate = userNetworkVideoCate1.subList(0, limit).stream()
                     .map(Pair::getValue)
                     .distinct()
                     .collect(Collectors.toList());
@@ -64,7 +65,7 @@ public class YearShareCate1RecallStrategy implements RecallStrategy {
                     .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet()
                     .stream()
                     .sorted(Map.Entry.<String, Long>comparingByValue().reversed())
-                    .limit(3)
+                    .limit(limit)
                     .map(Map.Entry::getKey)
                     .collect(Collectors.toList());
 

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

@@ -53,7 +53,8 @@ public class YearShareCate2RecallStrategy implements RecallStrategy {
             if (CollectionUtils.isEmpty(userNetworkVideoCate2)) {
                 return videosResult;
             }
-            List<String> lastTopNCate = userNetworkVideoCate2.subList(0, 3).stream()
+            int limit = Math.min(userNetworkVideoCate2.size(), 3);
+            List<String> lastTopNCate = userNetworkVideoCate2.subList(0, limit).stream()
                     .map(Pair::getValue)
                     .distinct()
                     .collect(Collectors.toList());
@@ -63,7 +64,7 @@ public class YearShareCate2RecallStrategy implements RecallStrategy {
                     .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet()
                     .stream()
                     .sorted(Map.Entry.<String, Long>comparingByValue().reversed())
-                    .limit(3)
+                    .limit(limit)
                     .map(Map.Entry::getKey)
                     .collect(Collectors.toList());