Sha256: 91cac128f4b1afcf7729ec0ab79ae83692757a4a4298f7861fd96e2cb8db04dc
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
require 'spec_helper' RSpec.describe OpenNlp::Categorizer do let(:model) { OpenNlp::Model::Categorizer.new(File.join(FIXTURES_DIR, 'en-doccat.bin')) } describe 'initialization' do it 'is initialized with a valid model' do categorizer = described_class.new(model) expect(categorizer.j_instance).to be_a(described_class.java_class) end it 'raises an ArgumentError without a valid model' do expect { described_class.new(nil) }.to raise_error(ArgumentError) end end describe '#categorize' do let(:categorizer) { described_class.new(model) } it 'categorizes a provided document to positive' do category = categorizer.categorize('The fox is a good worker.') expect(category).to eq('Positive') end it 'categorizes a provided document to negative' do category = categorizer.categorize('Quick brown fox jumps very bad.') expect(category).to eq('Negative') end it 'raises an ArgumentError when nil is passed as a param' do expect { categorizer.categorize(nil) }.to raise_error(ArgumentError) end it 'raises an ArgumentError when Fixnum is passed a param' do expect { categorizer.categorize(123) }.to raise_error(ArgumentError) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
open_nlp-0.3.0-java | spec/categorizer_spec.rb |
open_nlp-0.2.0-java | spec/categorizer_spec.rb |
open_nlp-0.1.0-java | spec/categorizer_spec.rb |