|
@@ -1,6 +1,9 @@
|
|
|
package com.tzld.longarticle.recommend.server.service.recommend.score.strategy;
|
|
|
|
|
|
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleTypeEnum;
|
|
|
import com.tzld.longarticle.recommend.server.remote.NLPRemoteService;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
|
|
|
import com.tzld.longarticle.recommend.server.service.recommend.score.Score;
|
|
|
import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreParam;
|
|
|
import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreStrategy;
|
|
@@ -23,6 +26,11 @@ public class SimilarityStrategy implements ScoreStrategy {
|
|
|
|
|
|
@Autowired
|
|
|
private NLPRemoteService nlpRemoteService;
|
|
|
+ @Autowired
|
|
|
+ private ArticleRepository articleRepository;
|
|
|
+
|
|
|
+ @ApolloJsonValue("${account.score.sim.replace:{}}")
|
|
|
+ private Map<String, String> accountSimScoreReplaceMap;
|
|
|
|
|
|
@Override
|
|
|
public List<Score> score(ScoreParam param) {
|
|
@@ -31,7 +39,15 @@ public class SimilarityStrategy implements ScoreStrategy {
|
|
|
if (CollectionUtils.isEmpty(param.getContents())) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
- Map<String, Double> scoreMap = nlpRemoteService.score(param.getGhId(), param.getAccountName(), param.getContents());
|
|
|
+ String ghId = param.getGhId();
|
|
|
+ if (accountSimScoreReplaceMap.containsKey(ghId)) {
|
|
|
+ int historyCount = articleRepository.countByGhIdAndTypeAndItemIndex(ghId,
|
|
|
+ ArticleTypeEnum.QUNFA.getVal(), 1);
|
|
|
+ if (historyCount < 10) {
|
|
|
+ ghId = accountSimScoreReplaceMap.get(ghId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Double> scoreMap = nlpRemoteService.score(ghId, param.getAccountName(), param.getContents());
|
|
|
|
|
|
// double min = scoreMap.values().stream()
|
|
|
// .min(Double::compareTo)
|