Class: TWSS::Engine
- Inherits:
-
Object
- Object
- TWSS::Engine
- Extended by:
- Forwardable
- Defined in:
- lib/twss/engine.rb
Constant Summary collapse
- DATA_FILE =
File.join(File.dirname(__FILE__), '../../data/classifier')
- TRUE =
'1'
- FALSE =
'0'
Instance Attribute Summary collapse
-
#threshold ⇒ Object
Returns the value of attribute threshold.
Instance Method Summary collapse
- #classify(str) ⇒ Object
-
#clear_state! ⇒ Object
Clears out the current classifier instance and nukes the data file.
-
#dump_classifier_to_file(f = @data_file) ⇒ Object
Dumps the current classifier state to specified path.
-
#initialize(options = {}) ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
Instance Attribute Details
#threshold ⇒ Object
Returns the value of attribute threshold.
16 17 18 |
# File 'lib/twss/engine.rb', line 16 def threshold @threshold end |
Instance Method Details
#classify(str) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/twss/engine.rb', line 24 def classify(str) if basic_conditions_met?(str) c = @classifier.classifications(str) require 'pp' c[TRUE] - c[FALSE] > threshold else false end end |
#clear_state! ⇒ Object
Clears out the current classifier instance and nukes the data file
42 43 44 45 |
# File 'lib/twss/engine.rb', line 42 def clear_state! File.delete(@data_file) if File.exists?(@data_file) @classifier = new_classifier end |
#dump_classifier_to_file(f = @data_file) ⇒ Object
Dumps the current classifier state to specified path
35 36 37 38 39 |
# File 'lib/twss/engine.rb', line 35 def dump_classifier_to_file(f = @data_file) o = File.open(f, 'w') o.write(Marshal.dump(@classifier)) o.close end |