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

前端 未结 6 588
别跟我提以往
别跟我提以往 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:40

    I know it has been a while since this was asked, but I encountered a similar problem and had a different solution.

    When you want to have a way to rank something, and there are multiple factors that you're using to perform that ranking, you're doing something called multi-criteria decision analysis. (MCDA). See: http://en.wikipedia.org/wiki/Multi-criteria_decision_analysis

    There are several ways to handle this. In your case, your criteria have different "units". One is in units of comments, the other is in units of views. Futhermore, you may want to give different weight to these criteria based on whatever business rules you come up with.

    In that case, the best solution is something called a weighted product model. See: http://en.wikipedia.org/wiki/Weighted_product_model

    The gist is that you take each of your criteria and turn it into a percentage (as was previously suggested), then you take that percentage and raise it to the power of X, where X is a number between 0 and 1. This number represents your weight. Your total weights should add up to one.

    Lastly, you multiple each of the results together to come up with a rank. If the rank is greater than 1, than the numerator page has a higher rank than the denominator page.

    Each page would be compared against every other page by doing something like:

    • p1C = page 1 comments
    • p1V = page 1 view
    • p2C = page 2 comments
    • p2V = page 2 views
    • wC = comment weight
    • wV = view weight

    rank = (p1C/p2C)^(wC) * (p1V/p2V)^(wV)

    The end result is a sorted list of pages according to their rank.

    I've implemented this in C# by performing a sort on a collection of objects implementing IComparable.

提交回复
热议问题