Class: NLPBackpack::Classifier::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/nlp_backpack/classifier/base.rb

Direct Known Subclasses

NaiveBayes

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#db_filepathObject

Returns the value of attribute db_filepath.



17
18
19
# File 'lib/nlp_backpack/classifier/base.rb', line 17

def db_filepath
  @db_filepath
end

Class Method Details

.load(db_path) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/nlp_backpack/classifier/base.rb', line 6

def load(db_path)
  data = ""
  File.open(db_path) do |f|
    while line = f.gets
      data << line
    end
  end
  Marshal.load(data)
end

Instance Method Details

#saveObject



19
20
21
22
23
24
# File 'lib/nlp_backpack/classifier/base.rb', line 19

def save
  raise "You haven't set a db_filpath, I dont know where to save" if @db_filepath.nil?
  File.open(@db_filepath, "w+") do |f|
    f.write(Marshal.dump(self))
  end
end