gem sources -a http://gemcutter.org sudo gem install tf_idf
require 'rubygems' require 'tf_idf' data = [%w{a a a a a a a a b b}, %w{a a}] a = TfIdf.new(data) # To find the term frequencies a.tf #=> [{'b' => 0.2, 'a' => etc...}, {'a' => 1}] # To find the inverse document frequency a.idf #=> {'b' => 0.301... etc...} # And to find the tf-idf a.tf_idf #=> [{'b' => 0.0602, 'a' => etc...}, {etc...}]
Copyright © 2009 Red Davis. See LICENSE for details.