import java.util.date;public class hotarticlerank {/************ * Enter the posting time, Returns the number of seconds from 1970.1.1 * @param Date dateTimes * @return */private static long epoch_seconds (Date pubtimes) {return pubtimes.gettime () / 1000 - 1134028003;} /****** * input top, step, return difference * @param ups * @param downs * @return */private static long score (long ups, long downs) {return ups - downs;} /****** * Calculate the Heat value, enter the top, step and post time, return the Heat value * @param ups number of articles at the top * @param downs article number of steps * @param pubtimes article release time * @return */public static double gethotval (long ups, long downs, date pubtimes) {double hotrank = 0;long seconds = 0;long scorecount = 0;double Order = 0;long signcount = 0;scorecount = score (ups, downs); seconds = epoch_seconds (pubtimes);//calculation of the degree of the post is positive (negative), if the evaluation of a post, the more one-sided, the greater the//order, but will tend to smooth. If the top equals stepping, then 0order = math.log10 (Math.max (Math.Abs (Scorecount), 1));signcount = (long) math.signum (Scorecount), the larger the//seconds, the higher the score, which means that the new post will score higher than the old post. It plays the role of automatically pulling down the rank of old posts. hotrank = order + (Signcount * seconds) / 45000;return hotrank;}}
This article is from the "Tranquility Zhiyuan" blog, please be sure to keep this source http://woodpecker.blog.51cto.com/2349932/1864339
Java implementation of Raddit algorithm