spec/selectors/simple_spec.rb in svm_helper-0.1.0 vs spec/selectors/simple_spec.rb in svm_helper-0.1.1
- old
+ new
@@ -1,11 +1,11 @@
require "spec_helper"
describe Selector::Simple do
it_behaves_like 'a selector'
-
- let(:simple) { Selector::Simple.new }
+
+ let(:simple) { Selector::Simple.new(:function) }
it "should have select_feature_vector implemented" do
expect { simple.generate_vectors([]) }.to_not raise_error
end
context "#stopwords" do
it "simply loads them from a file"
@@ -51,11 +51,12 @@
end
end
context "#generate_vector" do
let(:dictionary) { %w(auto pferd haus hase garten) }
let(:data) { FactoryGirl.build(:data) }
- let(:vector) { simple.generate_vector(data).tap{|e| e.career_level! } }
+ let(:simple) { Selector::Simple.new(:career_level) }
+ let(:vector) { simple.generate_vector(data) }
before(:each) do
simple.stubs(:global_dictionary).returns(dictionary)
end
it "should build a feature vector for each dataset with the size of the dictionary plus classifications" do
@@ -77,11 +78,11 @@
simple.expects(:make_vector).once
simple.generate_vector(data)
end
context "custom dictionary" do
it "should accept a custom dictionary" do
- vector = simple.generate_vector(data, :career_level, %w(pferd flasche glas))
+ vector = simple.generate_vector(data, %w(pferd flasche glas))
vector.data.should eq([[1,0,0],[0,0,0,0,0,0,1,0]].flatten)
end
end
end
context "#generate_vectors" do
@@ -104,10 +105,10 @@
simple.stubs(:extract_words).returns(words_per_data)
simple.expects(:make_vector).twice
simple.generate_vectors(data)
end
context "parallel" do
- let(:parallel) { Selector::Simple.new(parallel: true) }
+ let(:parallel) { Selector::Simple.new(:function, parallel: true) }
before(:each) do
simple.stubs(:global_dictionary).returns(dictionary)
parallel.stubs(:global_dictionary).returns(dictionary)
end
it "should be equal results in processes" do
\ No newline at end of file