Class Ankusa::MemoryStorage
In: lib/ankusa/memory_storage.rb
Parent: Object

Methods

Public Class methods

[Source]

# File lib/ankusa/memory_storage.rb, line 4
    def initialize
      init_tables
    end

Public Instance methods

[Source]

# File lib/ankusa/memory_storage.rb, line 8
    def classnames
      @total_doc_counts.keys
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 64
    def close
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 60
    def doc_count_totals
      @total_doc_counts
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 16
    def drop_tables
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 43
    def get_doc_count(klass)
      @total_doc_counts[klass]
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 39
    def get_total_word_count(klass)
      @total_word_counts[klass]
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 27
    def get_vocabulary_sizes
      count = Hash.new 0
      @freqs.each { |w, ks|
        ks.keys.each { |k| count[k] += 1 }
      }
      count
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 35
    def get_word_counts(word)
      @freqs.fetch word, Hash.new(0)
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 56
    def incr_doc_count(klass, count)
      @total_doc_counts[klass] += count
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 52
    def incr_total_word_count(klass, count)
      @total_word_counts[klass] += count
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 47
    def incr_word_count(klass, word, count)
      @freqs[word] ||= Hash.new(0)
      @freqs[word][klass] += count
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 19
    def init_tables
      @freqs = {}
      @total_word_counts = Hash.new(0)
      @total_doc_counts = Hash.new(0)
      @klass_word_counts = {}
      @klass_doc_counts = {}
    end

[Source]

# File lib/ankusa/memory_storage.rb, line 12
    def reset
      init_tables
    end

[Validate]