瀏覽代碼

Merge branch 'wyp/1023-scoreList-ghId' of Server/long-article-recommend into master

wangyunpeng 8 月之前
父節點
當前提交
d59b4605d8

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

@@ -50,12 +50,13 @@ public class NLPRemoteService {
     private static final String scoreListUrl = "http://61.48.133.26:6060/score_list";
     private static final String backUrl = "http://47.98.136.48:6060/score_list";
 
-    public Map<String, Double> score(String accountName, List<Content> contentList) {
+    public Map<String, Double> score(String ghId, String accountName, List<Content> contentList) {
         long start = System.currentTimeMillis();
         Map<String, Double> result = new HashMap<>();
         List<String> titleList = contentList.stream().map(Content::getTitle).collect(Collectors.toList());
         String url = scoreListUrl;
         JSONObject bodyParam = new JSONObject();
+        bodyParam.put("gh_id_list", Collections.singletonList(ghId));
         bodyParam.put("account_nickname_list", Collections.singletonList(accountName));
         bodyParam.put("text_list", titleList);
         bodyParam.put("interest_type", accountScoreInterestTypeMap.getOrDefault(accountName, "avg"));
@@ -84,7 +85,14 @@ public class NLPRemoteService {
 //                        log.info("scoreList 返回的数据:{}", responseBody);
                         JSONObject scoreListResponse = JSONObject.parseObject(responseBody);
                         if (Objects.nonNull(scoreListResponse)) {
-                            JSONObject accountScoreList = scoreListResponse.getJSONObject(accountName);
+                            Set<String> keySet = scoreListResponse.keySet();
+                            JSONObject accountScoreList = null;
+                            for (String key : keySet) {
+                                if (key.equals(accountName) || key.equals(ghId)) {
+                                    accountScoreList = scoreListResponse.getJSONObject(key);
+                                    break;
+                                }
+                            }
                             if (Objects.nonNull(accountScoreList)) {
                                 List<Double> scoreList = accountScoreList.getJSONArray("score_list").toJavaList(Double.class);
                                 for (int i = 0; i < contentList.size(); i++) {

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/strategy/SimilarityStrategy.java

@@ -31,7 +31,7 @@ public class SimilarityStrategy implements ScoreStrategy {
         if (CollectionUtils.isEmpty(param.getContents())) {
             return Collections.emptyList();
         }
-        Map<String, Double> scoreMap = nlpRemoteService.score(param.getAccountName(), param.getContents());
+        Map<String, Double> scoreMap = nlpRemoteService.score(param.getGhId(), param.getAccountName(), param.getContents());
 
 //        double min = scoreMap.values().stream()
 //                .min(Double::compareTo)