|
@@ -1,7 +1,6 @@
|
|
|
package com.tzld.longarticle.recommend.server.service.rank.strategy;
|
|
|
|
|
|
|
|
|
-import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
|
|
|
import com.tzld.longarticle.recommend.server.model.Content;
|
|
|
import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
|
|
|
import com.tzld.longarticle.recommend.server.service.rank.RankItem;
|
|
@@ -9,12 +8,11 @@ import com.tzld.longarticle.recommend.server.service.rank.RankParam;
|
|
|
import com.tzld.longarticle.recommend.server.service.rank.RankResult;
|
|
|
import com.tzld.longarticle.recommend.server.service.rank.RankStrategy;
|
|
|
import com.tzld.longarticle.recommend.server.service.score.AccountIndexReplacePoolConfig;
|
|
|
-import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
|
|
|
import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
|
|
|
import com.tzld.longarticle.recommend.server.service.score.ScoreService;
|
|
|
import com.tzld.longarticle.recommend.server.service.score.strategy.*;
|
|
|
import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
|
|
|
-import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
|
|
|
+import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
@@ -36,9 +34,9 @@ public class RankV10Strategy implements RankStrategy {
|
|
|
private AccountContentPoolConfigService accountContentPoolConfigService;
|
|
|
|
|
|
public RankResult rank(RankParam param) {
|
|
|
-
|
|
|
+ List<Content> result = new ArrayList<>();
|
|
|
//log.info("RankParam {}", JSONUtils.toJson(param));
|
|
|
- ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
|
|
|
+ ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
|
|
|
|
|
|
Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
|
|
|
String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
|
|
@@ -70,6 +68,11 @@ public class RankV10Strategy implements RankStrategy {
|
|
|
item.setScore(score);
|
|
|
return item;
|
|
|
});
|
|
|
+ // 相似度评分为0 报警返回
|
|
|
+ if (CollectionUtils.isNotEmpty(items) && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
|
|
|
+ FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容评分为0");
|
|
|
+ return new RankResult(result);
|
|
|
+ }
|
|
|
|
|
|
// 1 排序
|
|
|
Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
|
|
@@ -84,7 +87,6 @@ public class RankV10Strategy implements RankStrategy {
|
|
|
data.add(c);
|
|
|
}
|
|
|
// 4 选文章
|
|
|
- List<Content> result = new ArrayList<>();
|
|
|
String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
|
|
|
|
|
|
// 头
|
|
@@ -92,6 +94,7 @@ public class RankV10Strategy implements RankStrategy {
|
|
|
if (CollectionUtils.isNotEmpty(pool1)) {
|
|
|
result.add(pool1.get(0));
|
|
|
} else {
|
|
|
+ FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容池1为空");
|
|
|
return new RankResult(result);
|
|
|
}
|
|
|
// 次
|
|
@@ -134,33 +137,4 @@ public class RankV10Strategy implements RankStrategy {
|
|
|
return new RankResult(result);
|
|
|
}
|
|
|
|
|
|
- private ScoreParam convertToScoreParam(RankParam param) {
|
|
|
- ScoreParam scoreParam = new ScoreParam();
|
|
|
- scoreParam.setGhId(param.getGhId());
|
|
|
- scoreParam.setAccountName(param.getAccountName());
|
|
|
- scoreParam.setContents(param.getContents());
|
|
|
- scoreParam.setStrategy(param.getStrategy());
|
|
|
- scoreParam.setScene(param.getScene());
|
|
|
- return scoreParam;
|
|
|
- }
|
|
|
-
|
|
|
- private List<Content> deduplication(List<Content> contents) {
|
|
|
- List<String> titles = new ArrayList<>();
|
|
|
- List<Content> result = new ArrayList<>();
|
|
|
- // 遍历所有列表
|
|
|
- for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
|
|
|
- for (Content c : contents) {
|
|
|
- if (!contentPool.equals(c.getContentPoolType())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
|
|
|
- result.add(c);
|
|
|
- titles.add(c.getTitle());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
}
|