Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixing specs to use should be_within since exact floating point match…

…es are different across systems
  • Loading branch information...
commit 7726edadc170c83746a86baaa7dfb53f82417a39 1 parent 31c7348
@danmayer danmayer authored
View
12 spec/bigram_model_spec.rb
@@ -87,25 +87,29 @@
Ngram[:Deliverator, :belongs],
Ngram[:belongs, :to]
]
+ expected = '0.0112293144208038'.to_f
- @model.probability_of_ngrams(ngrams).to_s.should == '0.0112293144208038'
+ @model.probability_of_ngrams(ngrams).should be_within(0.0000000000000001).of(expected)
end
it "should have a probability for a specified fragment of text" do
fragment = %{The Deliverator belongs to}
+ expected = '0.0112293144208038'.to_f
- @model.fragment_probability(fragment).to_s.should == '0.0112293144208038'
+ @model.fragment_probability(fragment).should be_within(0.0000000000000001).of(expected)
end
it "should have a probability for a specified sentence" do
sentence = %{The Deliverator used to make software.}
+ expected = '4.10042780102381e-07'.to_f
- @model.sentence_probability(sentence).to_s.should == '4.10042780102381e-07'
+ @model.sentence_probability(sentence).should be_within(0.0000000000000001).of(expected)
end
it "should have a probability for specified text" do
text = %{The Deliverator used to make software. Still does, sometimes.}
+ expected = '2.40635434332383e-10'.to_f
- @model.text_probability(text).to_s.should == '2.40635434332383e-10'
+ @model.text_probability(text).should be_within(0.0000000000000001).of(expected)
end
end
View
6 spec/pentagram_model_spec.rb
@@ -89,13 +89,15 @@
it "should have a probability for a specified sentence" do
sentence = %{So now he has this other job.}
+ expected = '0.00117370892018779'.to_f
- @model.sentence_probability(sentence).to_s.should == '0.00117370892018779'
+ @model.sentence_probability(sentence).should be_within(0.0000000000000001).of(expected)
end
it "should have a probability for specified text" do
text = %{So now he has this other job. No brightness or creativity involved-but no cooperation either.}
+ expected = '2.75518525865679e-06'.to_f
- @model.text_probability(text).to_s.should == '2.75518525865679e-06'
+ @model.text_probability(text).should be_within(0.0000000000000001).of(expected)
end
end
View
6 spec/quadgram_model_spec.rb
@@ -94,13 +94,15 @@
it "should have a probability for a specified sentence" do
sentence = %{So now he has this other job.}
+ expected = '0.00117370892018779'.to_f
- @model.sentence_probability(sentence).to_s.should == '0.00117370892018779'
+ @model.sentence_probability(sentence).should be_within(0.0000000000000001).of(expected)
end
it "should have a probability for specified text" do
text = %{So now he has this other job. No brightness or creativity involved-but no cooperation either.}
+ expected = '2.75518525865679e-06'.to_f
- @model.text_probability(text).to_s.should == '2.75518525865679e-06'
+ @model.text_probability(text).should be_within(0.0000000000000001).of(expected)
end
end
View
13 spec/trigram_model_spec.rb
@@ -85,25 +85,28 @@
Ngram[:The, :Deliverator, :belongs],
Ngram[:Deliverator, :belongs, :to]
]
+ expected = '0.0526315789473684'.to_f
- @model.probability_of_ngrams(ngrams).to_s.should == '0.0526315789473684'
+ @model.probability_of_ngrams(ngrams).should be_within(0.0000000000000001).of(expected)
end
it "should have a probability for a specified fragment of text" do
fragment = %{The Deliverator belongs to}
+ expected = '0.0526315789473684'.to_f
- @model.fragment_probability(fragment).to_s.should == '0.0526315789473684'
+ @model.fragment_probability(fragment).should be_within(0.0000000000000001).of(expected)
end
it "should have a probability for a specified sentence" do
sentence = %{The Deliverator used to make software.}
+ expected = '0.000262540153199901'.to_f
- @model.sentence_probability(sentence).to_s.should == '0.000262540153199901'
+ @model.sentence_probability(sentence).should be_within(0.0000000000000001).of(expected)
end
it "should have a probability for specified text" do
text = %{The Deliverator used to make software. Still does, sometimes.}
-
- @model.text_probability(text).to_s.should == '6.16291439436388e-07'
+ expected = '6.16291439436388e-07'.to_f
+ @model.text_probability(text).should be_within(0.0000000000000001).of(expected)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.