Class: SourceClassifier
- Inherits:
-
Object
- Object
- SourceClassifier
- Defined in:
- lib/sourceclassifier.rb
Instance Attribute Summary collapse
-
#training_file ⇒ Object
readonly
Returns the value of attribute training_file.
Instance Method Summary collapse
- #identify(str) ⇒ Object
-
#initialize(training_file = nil) ⇒ SourceClassifier
constructor
A new instance of SourceClassifier.
- #languages ⇒ Object
Constructor Details
#initialize(training_file = nil) ⇒ SourceClassifier
Returns a new instance of SourceClassifier.
8 9 10 11 12 |
# File 'lib/sourceclassifier.rb', line 8 def initialize(training_file=nil) training_file = File.join(File.dirname(__FILE__), '..', 'trainer.bin') unless training_file @training_file = training_file open(@training_file, "r") { |f| @c = Marshal.load(f)} end |
Instance Attribute Details
#training_file ⇒ Object (readonly)
Returns the value of attribute training_file.
6 7 8 |
# File 'lib/sourceclassifier.rb', line 6 def training_file @training_file end |
Instance Method Details
#identify(str) ⇒ Object
18 19 20 |
# File 'lib/sourceclassifier.rb', line 18 def identify(str) @c.classify(str) end |
#languages ⇒ Object
14 15 16 |
# File 'lib/sourceclassifier.rb', line 14 def languages @c.categories end |