Simple, Automatic Text Classification in Ruby on Rails

Posted by Daniel Butler Thu, 18 May 2006 23:27:00 GMT

The ‘acts_as_classifiable’ plugin can be easily installed using gem install classifier --include-dependencies, and once simple 3-column table is added to your database to store the learned classification data, you’re ready to go. Add the following magic dust to the model you want

class Comment < ActiveRecords::Base
  acts_as_classifiable :fields => ["text","title"], 
    :categories => ["Ironic", "Boring"]
end

Train the classifier by using @comment.train :ironic or @comment.train :boring on existing objects, or collections of objects that have known classifications.

When a new @comment comes along, figure out what it is automatically with @comment.classify and act accordingly.

Enjoy.

Surendra’s blog entry about ‘acts_as_classifyable’

Posted in  | Tags ,  | 1 comment

Sponsored Links

Sponsored Links

Comments

  1. Avatar churi said 40 days later:

(leave url/email »)

   Comment Markup Help Preview comment