Algorithm to calculate a page importance based on its views / comments

前端 未结 6 693
别跟我提以往
别跟我提以往 2021-01-31 12:02

I need an algorithm that allows me to determine an appropriate field for my website\'s sitemap based on the page\'s views and comments count.

6条回答
  •  感动是毒
    2021-01-31 12:51

    The most naive approach would be the following:

    Let v[i] the views of page i, c[i] the number of comments for page i, then define the relative view weight for page i to be

    r_v(i) = v[i]/(sum_j v[j])
    

    where sum_j v[j] is the total of the v[.] over all pages. Similarly define the relative comment weight for page i to be

    r_c(i) = c[i]/(sum_j c[j]).
    

    Now you want some constant parameter p: 0 < p < 1 which indicates the importance of views over comments: p = 0 means only comments are significant, p = 1 means only views are significant, and p = 0.5 gives equal weight.

    Then set the priority to be

    p*r_v(i) + (1-p)*r_c(i)
    

    This might be over-simplistic but its probably the best starting point.

提交回复
热议问题