如何设计一个简单的关键字内容传递机制,其功能类似于Adwords

发布于 2024-12-06 22:40:41 字数 678 浏览 0 评论 0原文

我的应用程序允许用户存储长度约为 140 个字符的食物日记条目。我正在寻找一种解决方案,允许我根据条目中的关键字将内容模块(想想健康饮食的技巧)与用户的日记条目联系起来,类似于谷歌对adwords的做法。 Rails 中是否有任何开箱即用的解决方案可以做到这一点?

以下是具体要求:

  • 用户记录饮食日记条目
  • 在用户的饮食日记中,如果存在与该条目的关键字匹配的特定提示,则该提示将显示在该条目旁边
  • 提示将通过管理员工具定义指定提示内容和关键字,使其出现在日记中

尝试找出a)是否有一个预构建解决方案我可以用于类似的事情或b)自用户的食物日记以来最好的性能方法是什么可能有每页 20 个条目,并且必须对每个条目进行评估,看看是否有与条目关键字匹配的相应提示。

为了设计一个本土解决方案,我的一个想法是在存储新食物条目时进行提示关联,如下所示:

  1. 用户在保存后添加一个食物条目
  2. ,回调方法将条目分解为关键字并搜索提示模型以进行匹配
  3. 如果存在匹配,则在创建新条目时(而不是在网页中呈现用户的食物日记时)将其存储在关联表中。

存储新条目会对性能造成影响,但它可能允许用户的日记加载速度比渲染日记时执行所有这些查找更快。

这有意义吗,或者有更好的方法吗?更好的是,是否有工具可以完成我想要做的事情?

谢谢!

I'm have application that allows users to store food diary entries of approximately 140 characters in length. I am looking for a solution that will allow me to tie content modules (think tips for healthy eating) to the user's diary entries based on keywords in the entry similar to what Google does with adwords. Are there any out-of-the-box solutions that can do that in Rails?

Here are the specific requirements:

  • User logs food diary entry
  • In the user's food diary, if there's a specific tip that matches a keyword for the entry, then the tip is displayed next to the entry
  • Tips would be defined through an admin tool where the admin specifies the tip content and keywords that would make it appear in the diary

Trying to figure out a) if there's a pre-build solution I could use for something like this or b) what the best approach would be for performance since the users's food diary might have 20 entries per page, and each entry would have to be evaluated to see if there are any corresponding tips that match entry keywords.

For designing a home-grown solution, one idea I had was to make the tip associations when a new food entry is stored like this:

  1. user adds a food entry
  2. after_save a callback method breaks apart the entry into keywords and searches the tips model for matches
  3. if there's a match, it's stored in an association table when new entries are created rather then when the user's food diary is rendered in the web page.

There's a performance hit on storing new entries, but it might allow the user's diary to load faster then doing all those look-ups when the diary is rendered.

Does that make sense, or is there a better way? better yet, are there tools that can accomplish what I'm trying to do?

Thanks!

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

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

发布评论

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

评论(1

寂寞花火° 2024-12-13 22:40:41

这不是 AdWords API 问题,但我会尝试一下:

  1. 我会将关联表构建移至离线任务/定时任务中。这将解决创建新条目时的性能开销,并且如果用户碰巧过早查看该主题,通常会接受诸如“正在生成提示,请耐心等待”之类的消息。

  2. 我不知道任何现有的解决方案,但这对我来说听起来像是一个标签系统。基本上,您有两个列表(食品乳制品条目、提示),您希望为两个列表分配主题标签,然后将条目与相同的主题标签配对。谷歌搜索主题标签系统/库可能是一个很好的起点。

干杯,
阿纳什

This is not an AdWords API question, but I'll take a shot:

  1. I would move the association table building into an offline task / cronjob. That would take care of the performance overhead when creating new entries, and users would be generally okay with a message like "Tips are being generated, please be patient" if they happen to view the topic too soon.

  2. I'm not aware of any existing solutions, but this sounds like a hashtag system to me. Basically you have two lists (food dairy entries, tips), you want to assign hashtags to both lists and then pair entries with same hashtags. Googling for a hashtag system / library might be a good starting point.

Cheers,
Anash

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