Sha256: b0ff1bc8a772fe4fa829d97d316d6c1d1baf79b84fc120f5d482021a2ccfcdbf

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require File.join(File.dirname(__FILE__), "..", "spec_helper")

describe FeatureExtractor do
  DocumentMock = Struct.new(:vector_of_features)

  it "should save to file"
  it "should be loadable from file"
  
  it "should return number of features" do
    FeatureExtractor.new(%w[one two]).number_of_features.should == 2 
  end
  
  it "should throw away extra features" do
    doc = DocumentMock.new([Feature.new("keep"), Feature.new("throwaway")])
    FeatureExtractor.new(%w[keep]).extract(doc).should == [Feature.new("keep")]
  end
  
  it "should extract no features from a doc with no features" do
    FeatureExtractor.new(%w[keep]).extract(DocumentMock.new([])).should == []
  end
  
  it "should extract numbered features" do
    doc = DocumentMock.new([Feature.new("keep", 0)])
    FeatureExtractor.new(%w[keep]).extract_numbered(doc).should == [Feature.new(1, 0)]
  end
  
  it "should sort extracted numbered features" do
    feature_extractor = FeatureExtractor.new(%w[keep1 keep2])
    doc = DocumentMock.new([Feature.new("keep2", 10), Feature.new("keep1", 20)])
    feature_extractor.extract_numbered(doc).should == [Feature.new(1, 20), Feature.new(2, 10)]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
basset-1.0.0 spec/unit/feature_extractor_spec.rb
basset-1.0.1 spec/unit/feature_extractor_spec.rb