wangyunpeng 11 months ago
parent
commit
eeae1d9cd1

+ 8 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/HttpPoolFactory.java

@@ -13,6 +13,10 @@ public final class HttpPoolFactory {
     private static CloseableHttpClient AIGC =
             HttpClientFactory.create(10000, 10000, 200, 200, 0, 10000);
 
+    private static CloseableHttpClient NLP =
+            HttpClientFactory.create(15000, 15000, 200, 200, 0, 15000);
+
+
     public static CloseableHttpClient defaultPool() {
         return DEFAULT;
     }
@@ -21,4 +25,8 @@ public final class HttpPoolFactory {
         return AIGC;
     }
 
+    public static CloseableHttpClient nlpPool() {
+        return NLP;
+    }
+
 }

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/NLPRemoteService.java

@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
 @Slf4j
 public class NLPRemoteService {
 
-    private final CloseableHttpClient client = HttpPoolFactory.defaultPool();
+    private final CloseableHttpClient client = HttpPoolFactory.nlpPool();
     private static final String scoreListUrl = "http://192.168.100.31:8179/score_list";
 
     public Map<String, Double> score(String accountName, List<Content> contentList) {

+ 12 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/FilterService.java

@@ -3,7 +3,9 @@ package com.tzld.longarticle.recommend.server.service.filter;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
-import com.tzld.longarticle.recommend.server.service.filter.strategy.*;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.BadStrategy;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.HistoryTitleStrategy;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.SensitiveStrategy;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.JSONUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -11,7 +13,9 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
@@ -54,12 +58,18 @@ public class FilterService {
 
         List<List<String>> contentIdsList = new ArrayList<>();
         List<Content> filterContents = new ArrayList<>();
+        Set<String> filterContentIds = new HashSet<>();
         for (Future<FilterResult> f : futures) {
             try {
                 FilterResult filterResult = f.get();
                 contentIdsList.add(filterResult.getContentIds());
                 if (CollectionUtils.isNotEmpty(filterResult.getFilterContent())) {
-                    filterContents.addAll(filterResult.getFilterContent());
+                    for (Content content : filterResult.getFilterContent()) {
+                        if (!filterContentIds.contains(content.getId())) {
+                            filterContentIds.add(content.getId());
+                            filterContents.add(content);
+                        }
+                    }
                 }
             } catch (Exception e) {
                 log.error("future get error ", e);

+ 0 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/HistoryTitleStrategy.java

@@ -45,7 +45,6 @@ public class HistoryTitleStrategy implements FilterStrategy {
         List<Article> allArticleList = articleListRemoteService.articleList(param.getAccountName(), allIndex);
         List<String> allTitleList = allArticleList.stream().map(Article::getTitle).collect(Collectors.toList());
 
-
         List<String> firstSecondContentPool = new ArrayList<>();
         String[] contentPoolConfig = accountContentPoolConfigService.getContentPools(param.getAccountName());
         if (Objects.nonNull(contentPoolConfig)) {

BIN
long-article-recommend-service/target/test-classes/com/tzld/piaoquan/recommend/test/merger/MergeUtilsTest.class