如何更新Hacker News算法等内容流行度评分?

发布于 2024-09-27 01:00:29 字数 234 浏览 0 评论 0原文

我正在为我的社交网站(具有大量点赞和评论的项目)使用定制版本的 Hacker News 流行度算法。该算法工作完美,但我不知道如何正确更新项目评分(我将分数存储在项目模型中作为元数据)。

现在,我只是更新过去 9 天内列出的每个新点赞和评论的分数。这真的很慢并且资源繁重,所以我正在寻找一种更好的方法来保持分数最新。问题是,当每一项发生变化时,每一项都需要一个新的分数,以保持时间的衰减。更好的方法是什么?我在该项目中使用 Django。

I'm using a customized version of Hacker News popularity algorithm for my social site (items with a number of likes and comments). The algorithm works perfectly but I don't know how to update item scorings correctly (I'm storing the score in item model as meta data).

Now I'm just updating scores on every new like and comment for items listed during past 9 days. This is really slow and resource heavy so I'm looking for a better way to keep scores up to date. Problem is that every item needs a new score when one changes to keep the time decay. What would be the better way to do this? I'm using Django for the project.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里泪两行 2024-10-04 01:00:29

好的。我已经使用不同的应用程序完成了:
首先,您需要在 github 上安装“dokterbob/django-popularity”或“thornomad/django-hitcount”来跟踪链接的访问频率。

其次,您需要计算对象收到的投票数(喜欢或收藏)。为此,您可以尝试“brosner/django-voting”、“apgwoz/django-favorites”。

现在你必须使用这段代码 --django-populars 将它们全部放在一起。
我建议查看此代码首先看看它是如何工作的,了解如何将所需的组件组合在一起。

OK. I have done it using different apps:
First, you need to install either "dokterbob/django-popularity" on github or "thornomad/django-hitcount" to track how often a link is visited.

Second, you need to count how many votes (likes or favorites) an object receives. For that purpose, you can try "brosner/django-voting", "apgwoz/django-favorites".

Now you have to use this piece of code --django-populars to put them all together.
I would recommend looking into this code first of all to see how it works to understand how to put together the needed components.

﹂绝世的画 2024-10-04 01:00:29

有多种方法可以做到这一点。一种简单的方法是按顺序对项目进行编号,并以每个项目的 ID 号的“排名 ID”开始。每当一个帖子被评级时,就增加它的排名号(对于反对票,反之亦然)。然后,按排名编号排序以正确排序项目。

另一种选择是指数衰减模型,它需要定期更新,但这些可以通过投票来支持,从而减少您必须执行的批量更新工作量。我在此处写了一篇关于实现该功能的文章。它针对的是 App Engine,但通常很有用。

There's a number of ways to do this. One simple way is to number items sequentially, and start each item with a 'rank id' of its ID number. Whenever a post is rated up, increment its rank number (and vice-versa for down votes). Then, sort by rank number to order items correctly.

Another option is an exponential decay model, which requires periodic updates, but these can be piggy backed on votes, reducing the amount of batch-update work you have to do. I wrote an article about implementing that here. It's targeted at App Engine, but generally useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文