1

我想知道从输入文本(在用户输入时)生成标签云的最佳方法是什么。例如,如果用户键入包含关键字“sci-fi, technology, effects”的故事文本,标签云将由每个关键字根据它们在每个故事中的频率按相关性排序形成。标签云将按降序显示并使用相同的字体大小,这不是显示算法,而是我应该实现的搜索算法。我正在使用mysql和php。我应该坚持 MATCH...AGAINST 条款吗?我应该实现标签表吗?

更多细节 我有一个包含很多故事的 mysql 表。当用户键入他/她自己的一个时,我想显示一个标签云,其中包含从输入文本中获取的最常见单词,这些单词出现在保存在我的数据库中的这组故事中。标签云将仅用于根据他们在所有用户输入的所有故事中出现的频率,向用户显示他/她输入的单词在他/她自己的故事中的相关性。

4

2 回答 2

0

I think the first thing you need to do is more clearly define the purpose of your tagging system. Do you want to simply build tags based on the words that occur most frequently within the text? This strikes me as something designed with search rankings in mind.

...Or do you want your content to be better organized, and the tag cloud be a way of providing a better user experience and creating more distinct relationships between pieces of content (ie both of these are tagged sci-fi, so display them in the sci-fi category).

If the former is the case, you might not need to do anything but:

Then you just need to decide how many times a word has to occur (either percentage or numeric), and store those tags in a table that shows the connection between tags and content.

To implement the "as the user is typing" part you just need to use a bit of jQuery's ajax functionality to continually call your script that builds the tag list (ie on keydown).

The other option (better user experience) will incorporate a lot of the same elements, but you'll have to think about a bit more. Some things I would consider:

  • Do you want to restrict to certain tags (perhaps you don't want to allow just anyone to create new tags)?
  • How you will deal with synonyms
  • If you will support multiple languages
  • If you want a preference towards suggesting existing tags (which might be close) over suggesting new ones

Once you've fully defined the logic and user experience you can come back to the search algorithm. MATCH and AGAINST are good options but you may find that a simple LIKE will do it for you.

Good luck = )

于 2011-07-18T04:00:34.957 回答
0

如果您希望在用户键入时生成标签云,您可以通过两种方式进行。

  • 直接从输入文本更新标签云
  • 将输入文本发送到后端(使用 ajax/comet 实时),然后保存、计算词频并返回生成云的数据。

我会使用 jQuery 插件,例如 - http://plugins.jquery.com/plugin-tags/tag-cloud

于 2011-07-18T12:36:50.703 回答