Sha256: 1acae5e71d6163b734b3c32fca83ed0d3419a168cfd2211e4ce1dfe7d0fadc83

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

module Semantic
  module VectorSpace
    describe Builder do

      def mock_parser
        @parser ||= mock("Parser")
      end

      def documents
        ['nipon','ichiban']
      end


      describe "building query vector" do

        it "should build vector from string" do
          builder = Builder.new
          builder.should_receive(:build_vector).with("query string")

          builder.build_query_vector(["query","string"])
        end

        it "should generate a valid vector" do
          builder = Builder.new
          builder.build_document_matrix(["query string"])
          query = builder.build_query_vector(["query","string"])

          query.should == Linalg::DMatrix.columns([[1,1]])
        end

        it "should generate empty vector when terms are not in document matrix" do
          builder = Builder.new
          builder.build_document_matrix(["string"])
          query = builder.build_query_vector(["not-in-document"])

          query.should == Linalg::DMatrix.columns([[0]])
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
josephwilk-rsemantic-0.1.0 spec/semantic/vector_space/builder_spec.rb
josephwilk-rsemantic-0.1.1 spec/semantic/vector_space/builder_spec.rb
josephwilk-rsemantic-0.1.2 spec/semantic/vector_space/builder_spec.rb
josephwilk-rsemantic-0.1.3 spec/semantic/vector_space/builder_spec.rb
josephwilk-semantic-0.1.0 spec/semantic/vector_space/builder_spec.rb
rsemantic-0.1.3 spec/semantic/vector_space/builder_spec.rb