Permalink
Browse files

Only the size is needed to initialize a VersionSpace.

  • Loading branch information...
1 parent 4c0abff commit 2501e5346bacc7e4b431d141de693158fef93fa4 @arthurschreiber committed Apr 13, 2011
Showing with 10 additions and 11 deletions.
  1. +3 −1 ruby/example/aq_algorithm.rb
  2. +3 −3 ruby/lib/version_space.rb
  3. +4 −7 ruby/spec/version_space_spec.rb
@@ -19,7 +19,9 @@
until positive_beispiele.empty?
a = positive_beispiele.shift
- vs = VersionSpace.new([[:*] * (a.size - 1)], [a[0..-2]])
+ vs = VersionSpace.new(a.size - 1)
+ vs.positive_example(a[0..-2])
+
negative_beispiele.each do |bsp|
break if vs.terminated?
vs.negative_example bsp[0..-2]
@@ -1,9 +1,9 @@
class VersionSpace
attr_reader :s, :g
- def initialize(g, s)
- @g = g
- @s = s
+ def initialize(size)
+ @g = [[:*] * size]
+ @s = [[:_] * size]
@positive_examples = []
end
@@ -3,7 +3,7 @@
describe VersionSpace do
before :each do
- @vs = VersionSpace.new([[:*, :*, :*]], [[:_, :_, :_]])
+ @vs = VersionSpace.new(3)
end
it "should be correctly building a version space for the 'Sänger/Sängerin' example" do
@@ -37,10 +37,7 @@
end
it "should be correctly building a version space for the 'Autokauf'" do
- @vs = VersionSpace.new(
- [[:*, :*, :*, :*, :*, :*, :*, :*, :*, :*, :*]],
- [[:_, :_, :_, :_, :_, :_, :_, :_, :_, :_, :_]]
- )
+ @vs = VersionSpace.new(11)
@vs.positive_example(["neu", "VW", "90-120", "< 2 l", "< 180", "Diesel", "< 6 l", "Minivan", "8", "silber/grau", "< 25000"])
@vs.g.should == [[:*, :*, :*, :*, :*, :*, :*, :*, :*, :*, :*]]
@@ -151,8 +148,8 @@
@vs.should be_terminated
end
- it "should fail to build a VersionSpace for the example 'Fußball'" do
- @vs = VersionSpace.new([[:*, :*]], [[:_, :_]])
+ it "should terminate when trying to build a VersionSpace for the example 'Fußball'" do
+ @vs = VersionSpace.new(2)
@vs.positive_example(["rund", "schwarzrot"])
@vs.positive_example(["rund", "schwarzweiss"])

0 comments on commit 2501e53

Please sign in to comment.