Class: Dictionary

Inherits:
Object
  • Object
show all
Defined in:
lib/rbbt/bow/dictionary.rb

Defined Under Namespace

Classes: KL, TF_IDF

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDictionary

Returns a new instance of Dictionary.



3
4
5
# File 'lib/rbbt/bow/dictionary.rb', line 3

def initialize
  @terms = Hash.new(0)
end

Instance Attribute Details

#termsObject (readonly)

Returns the value of attribute terms.



2
3
4
# File 'lib/rbbt/bow/dictionary.rb', line 2

def terms
  @terms
end

Instance Method Details

#add(terms, &block) ⇒ Object



7
8
9
10
11
# File 'lib/rbbt/bow/dictionary.rb', line 7

def add(terms, &block)
  terms.each{|term, count|
    @terms[term] += count
  }
end