Java implementation of Raddit algorithm

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.