Skip to content

reddavis/TF-IDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tf-Idf

en.wikipedia.org/wiki/Tf–idf

Install

gem sources -a http://gemcutter.org
sudo gem install tf_idf

How To Use

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.

About

Term Frequency - Inverse Document Frequency in Ruby

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages