排名算法 安装 $ go get github.com/alextanhongpin/go-rate 跑 func main () { upvotes := 1000 downvotes := 10 score := rate . Wilson ( upvotes , downvotes ) // or createdAt := time . Now () score := rate . Hot ( upvotes , downvotes , createdAt ) } 按Wilson-Score间隔排序 Reddit评论排名使用Wilson-Score区间 Wilson-Score时间间隔公式显示如下: p-hat是赞成票占总数的分数 n是赞成和反对的总数 这是用go编写的算法的示例: func Wilson ( upvotes , downvotes int64 ) float64 { n := float64 ( upvotes + downvotes ) // if n == 0.0 { return 0 } will return false
2021-02-02 16:37:43 43KB go algorithm reddit wilson-score
1