Commit da281864 authored by 刘基明's avatar 刘基明

热度算法优化 参数fix

parent 488a1b72
...@@ -22,8 +22,6 @@ public class ThemeAnalysDO { ...@@ -22,8 +22,6 @@ public class ThemeAnalysDO {
@ApiModelProperty(value = "作者id") @ApiModelProperty(value = "作者id")
private String authorId; private String authorId;
@ApiModelProperty(value = "被转发的主题")
private String formerThemeId;
@ApiModelProperty(value = "所属的话题") @ApiModelProperty(value = "所属的话题")
private String topicId; private String topicId;
...@@ -44,7 +42,7 @@ public class ThemeAnalysDO { ...@@ -44,7 +42,7 @@ public class ThemeAnalysDO {
private Integer viewCount; private Integer viewCount;
@ApiModelProperty(value = "距今时间") @ApiModelProperty(value = "距今时间")
private Long minuteTillNow; private Long hoursTillNow;
@ApiModelProperty(value = "用户质量") @ApiModelProperty(value = "用户质量")
private Double userWeight = 0.0; private Double userWeight = 0.0;
......
...@@ -175,12 +175,14 @@ public class RankService { ...@@ -175,12 +175,14 @@ public class RankService {
.sum(); .sum();
topic.setThemeWeight(themeSum); topic.setThemeWeight(themeSum);
} }
// 打分
calculateTopicScore(topic); calculateTopicScore(topic);
//格式化浏览量、讨论量 // 格式化浏览量、讨论量
topic.setFormatViewCount(BizUtils.formatCountNumber(topic.getViewCount())); topic.setFormatViewCount(BizUtils.formatCountNumber(topic.getViewCount()));
topic.setFormatDisscussCount(BizUtils.formatCountNumber(topic.getDisscussCount())); topic.setFormatDisscussCount(BizUtils.formatCountNumber(topic.getDisscussCount()));
} }
// 排序
Map<TopicRankQo, Double> map = topicRankQos.stream().collect(Collectors.toMap(o -> o, TopicRankQo::getScore)); Map<TopicRankQo, Double> map = topicRankQos.stream().collect(Collectors.toMap(o -> o, TopicRankQo::getScore));
List<TopicRankQo> rankList = map.entrySet().stream() List<TopicRankQo> rankList = map.entrySet().stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
...@@ -258,8 +260,7 @@ public class RankService { ...@@ -258,8 +260,7 @@ public class RankService {
+ theme.getLikeCount() * likeRaten + theme.getLikeCount() * likeRaten
+ theme.getCollectCount() * collectRate + theme.getCollectCount() * collectRate
+ Math.pow(theme.getUserWeight(), userWeightRate); + Math.pow(theme.getUserWeight(), userWeightRate);
double t = Double.valueOf(theme.getMinuteTillNow()) / 60; double score = (w + initialWeight) / Math.pow(theme.getHoursTillNow() + 1, timeRate);
double score = (w + initialWeight) / Math.pow(t + 1, timeRate);
theme.setScore(score); theme.setScore(score);
} }
......
...@@ -47,7 +47,7 @@ public class ConvertUtil { ...@@ -47,7 +47,7 @@ public class ConvertUtil {
} }
ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO(); ThemeAnalysDO themeAnalysDO = new ThemeAnalysDO();
BeanUtils.copyProperties(themeEntity, themeAnalysDO); BeanUtils.copyProperties(themeEntity, themeAnalysDO);
themeAnalysDO.setMinuteTillNow(TimeUtils.calMinuteTillNow(themeEntity.getCreateTime())); themeAnalysDO.setHoursTillNow(TimeUtils.calHoursTillNow(themeEntity.getCreateTime()));
return themeAnalysDO; return themeAnalysDO;
} }
......
...@@ -98,16 +98,16 @@ recommend: ...@@ -98,16 +98,16 @@ recommend:
rank: rank:
theme: theme:
viewRatio: 0.1 viewRate: 0.11
forwardRatio: 3 forwardRate: 31
commentRatio: 2 commentRate: 21
likeRation: 1 likeRaten: 11
collectRatio: 3 collectRate: 31
userWeightRatio: 0.9 userWeightRate: 0.91
initialWeight: 1.0 initialWeight: 1.011
timeRation: 0.2 timeRate: 0.21
topic: topic:
viewRate: 2 viewRate: 21
discussRate: 3 discussRate: 31
themeRate: 3 themeRate: 31
timeRate: 1 timeRate: 11
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment