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

热度算法优化 参数fix

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