|
@@ -11,7 +11,7 @@ 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.SimilarityStrategy;
|
|
|
-import com.tzld.longarticle.recommend.server.service.score.strategy.ViewCountStrategy;
|
|
|
+import com.tzld.longarticle.recommend.server.service.score.strategy.ViewMultiplierStrategy;
|
|
|
import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
|
|
|
import com.tzld.longarticle.recommend.server.util.JSONUtils;
|
|
|
import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
|
|
@@ -47,23 +47,14 @@ public class RankV3Strategy implements RankStrategy {
|
|
|
RankItem item = new RankItem();
|
|
|
item.setContent(c);
|
|
|
item.setScoreMap(scoreMap.get(c.getId()));
|
|
|
+ double score = 2 * item.getScore(SimilarityStrategy.class.getSimpleName())
|
|
|
+ + item.getScore(ViewMultiplierStrategy.class.getSimpleName())
|
|
|
+ item.setScore(score);
|
|
|
return item;
|
|
|
-
|
|
|
});
|
|
|
|
|
|
// 1 排序
|
|
|
- Collections.sort(items, (o1, o2) -> {
|
|
|
- int result = -Double.compare(
|
|
|
- o1.getScore(SimilarityStrategy.class.getSimpleName()),
|
|
|
- o2.getScore(SimilarityStrategy.class.getSimpleName()));
|
|
|
- if (result != 0) {
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- return -Double.compare(
|
|
|
- o1.getScore(ViewCountStrategy.class.getSimpleName()),
|
|
|
- o2.getScore(ViewCountStrategy.class.getSimpleName()));
|
|
|
- });
|
|
|
+ Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore());
|
|
|
// 2 相似去重
|
|
|
List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
|
|
|
log.info("Sort result {}", JSONUtils.toJson(contents));
|