Sha256: 7640b9e819343c3d84a59bbd85173beb4dbab079b469a1bd5bb35d30783222b1

Contents?: true

Size: 986 Bytes

Versions: 1

Compression:

Stored size: 986 Bytes

Contents

require 'spec_helper'

describe ::Bae::Classifier do

  subject { described_class.new }

  it "can classify from ruby to java with a hash document" do
    subject.train("positive", {"aaa" => 0, "bbb" => 1})
    subject.train("negative", {"ccc" => 2, "ddd" => 3})

    subject.finish_training!

    results = subject.classify({"aaa" => 1, "bbb" => 1})

    expect(results["positive"]).to be_within(0.001).of(0.94117)
    expect(results["negative"]).to be_within(0.001).of(0.05882)
  end

  it "can classify from ruby to java with a string based document" do
    subject.train("positive", "aaa aaa bbb");
    subject.train("negative", "ccc ccc ddd ddd");
    subject.train("neutral", "eee eee eee fff fff fff");

    subject.finish_training!

    results = subject.classify("aaa bbb")

    expect(results["positive"]).to be_within(0.001).of(0.89626)
    expect(results["negative"]).to be_within(0.001).of(0.06639)
    expect(results["neutral"]).to be_within(0.001).of(0.03734)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bae-0.0.7-java spec/lib/bae/classifier_spec.rb