Class: Frekwenza::TfIdf

Inherits:
Object
  • Object
show all
Defined in:
lib/frekwenza/tf_idf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(docs, limit, stop_words = nil) ⇒ TfIdf

Returns a new instance of TfIdf.



5
6
7
8
9
10
11
12
13
# File 'lib/frekwenza/tf_idf.rb', line 5

def initialize(docs, limit, stop_words=nil)
  @docs = split_docs(docs)
  @tf = []
  @idf = {}
  @tf_idf = []
  @docs_size = @docs.size
  calculate_tf_and_idf
  calculate_tf_idf(limit, stop_words)
end

Instance Attribute Details

#idfObject (readonly)

Returns the value of attribute idf.



3
4
5
# File 'lib/frekwenza/tf_idf.rb', line 3

def idf
  @idf
end

#tfObject (readonly)

Returns the value of attribute tf.



3
4
5
# File 'lib/frekwenza/tf_idf.rb', line 3

def tf
  @tf
end

#tf_idfObject (readonly)

Returns the value of attribute tf_idf.



3
4
5
# File 'lib/frekwenza/tf_idf.rb', line 3

def tf_idf
  @tf_idf
end