views:

39

answers:

3

Given an article's title, I would like to find all the similar articles in my blog based on the title only.

How would you proceed?

(I use postgresql and heroku)

A: 

You can do something like this:

title = "existing article title"
@articles = Article.find(:conditions => ["title LIKE ?", "%#{title}%"])

For Rails 3, it would be:

title = "existing article title"
@articles = Article.where(["title LIKE ?", "%#{title}%"])
John Topley
Unfortunately, this doesn't find the similarity between "How to install a new plugin in Wordpress" and "Why wordpress totally rocks!"
Aymeric
You didn't really specify that in your original question.
John Topley
A: 

Judging from your last comment, you're targeting a pretty complex problem here. You can go here and have a look at a project from Stanford's Natural Language Processing Group, which tries to identify nouns, adjectives, verbs, etc. for a sentence. I would start by identifying the nouns in your post title and then search for those nouns in the database.

Kitto
+1  A: 

Go with the Websolr full test search heroku addon, and use the sunspot search engine. That way you can use full text searching, and it'll do all the word searches for you.

http://addons.heroku.com/websolr

http://outoftime.github.com/sunspot/

Jesse Wolgamott