Class: Frekwenza::TfIdf
- Inherits:
-
Object
- Object
- Frekwenza::TfIdf
- Defined in:
- lib/frekwenza/tf_idf.rb
Instance Attribute Summary collapse
-
#idf ⇒ Object
readonly
Returns the value of attribute idf.
-
#tf ⇒ Object
readonly
Returns the value of attribute tf.
-
#tf_idf ⇒ Object
readonly
Returns the value of attribute tf_idf.
Instance Method Summary collapse
-
#initialize(docs, limit, stop_words = nil) ⇒ TfIdf
constructor
A new instance of TfIdf.
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
#idf ⇒ Object (readonly)
Returns the value of attribute idf.
3 4 5 |
# File 'lib/frekwenza/tf_idf.rb', line 3 def idf @idf end |
#tf ⇒ Object (readonly)
Returns the value of attribute tf.
3 4 5 |
# File 'lib/frekwenza/tf_idf.rb', line 3 def tf @tf end |
#tf_idf ⇒ Object (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 |