views:

37

answers:

2

Let's say I want to trend all comments posted on a site and create dynamic tags. For example, If there are x number of comments that contain the word iPad I would like to create automatically create a tag called "iPad" and put it in a tag cloud.

Is this possible? I checked out the acts_as_taggable gem but it requires one to specify a tag, I guess I am looking for a way to generate tags from content.

A: 

Sure, this is possible. Just parse the content of each comment as it's passed in and attach the tags you're interested in.

This can either work on a whitelist - where you specify all the tags you're interested in and attach those if relevant.

Or it could work on a blacklist - where you specify all the words to ignore, e.g. "the", "on". This approach is probably a lot more time consuming, but would allow for more dynamic results.

I would probably work on a white list, then have an ability to add new tags to the whitelist and have it go back and retroactively add the tags where applicable.

Jamie Wong
Thanks. It's the parsing part where I was hoping a gem could help. It's not just parsing, but figuring out what keywords to actually look for i.e. what keywords have been on an upward trend. It seems kinda complex
badnaam
@badnaam, you might just want to maintain a table of the top 200 words in all your posts and generate tags for the top 100 or so. When you add a new post, add its words into the 200-table if possible. Periodically rebuild the 200-table from all the posts to make sure you're tracking the right words.
sarnold
+1  A: 

Well something like the yahoo term extraction service might do the trick and there is a plugin for it http://expressica.com/auto_tags/.

Though it is not for commercial use.

badnaam