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)
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)
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}%"])
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.
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.