stamina 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +22 -5
- data/LICENCE.md +2 -2
- data/bin/stamina +1 -7
- data/lib/stamina.rb +10 -19
- metadata +54 -333
- data/.gemtest +0 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -37
- data/Manifest.txt +0 -16
- data/README.md +0 -78
- data/Rakefile +0 -23
- data/example/adl/automaton.adl +0 -49
- data/example/adl/sample.adl +0 -53
- data/example/basic/characteristic_sample.adl +0 -32
- data/example/basic/target.adl +0 -9
- data/example/competition/31_test.adl +0 -1500
- data/example/competition/31_training.adl +0 -1759
- data/lib/stamina/abbadingo.rb +0 -2
- data/lib/stamina/abbadingo/random_dfa.rb +0 -48
- data/lib/stamina/abbadingo/random_sample.rb +0 -146
- data/lib/stamina/adl.rb +0 -298
- data/lib/stamina/automaton.rb +0 -1263
- data/lib/stamina/automaton/complete.rb +0 -36
- data/lib/stamina/automaton/equivalence.rb +0 -55
- data/lib/stamina/automaton/metrics.rb +0 -78
- data/lib/stamina/automaton/minimize.rb +0 -25
- data/lib/stamina/automaton/minimize/hopcroft.rb +0 -116
- data/lib/stamina/automaton/minimize/pitchies.rb +0 -64
- data/lib/stamina/automaton/strip.rb +0 -16
- data/lib/stamina/automaton/walking.rb +0 -363
- data/lib/stamina/classifier.rb +0 -52
- data/lib/stamina/command.rb +0 -45
- data/lib/stamina/command/abbadingo_dfa.rb +0 -81
- data/lib/stamina/command/abbadingo_samples.rb +0 -40
- data/lib/stamina/command/adl2dot.rb +0 -71
- data/lib/stamina/command/classify.rb +0 -48
- data/lib/stamina/command/help.rb +0 -27
- data/lib/stamina/command/infer.rb +0 -141
- data/lib/stamina/command/metrics.rb +0 -51
- data/lib/stamina/command/robustness.rb +0 -22
- data/lib/stamina/command/score.rb +0 -35
- data/lib/stamina/errors.rb +0 -23
- data/lib/stamina/ext/math.rb +0 -20
- data/lib/stamina/induction/blue_fringe.rb +0 -265
- data/lib/stamina/induction/commons.rb +0 -156
- data/lib/stamina/induction/rpni.rb +0 -186
- data/lib/stamina/induction/union_find.rb +0 -377
- data/lib/stamina/input_string.rb +0 -123
- data/lib/stamina/loader.rb +0 -1
- data/lib/stamina/markable.rb +0 -42
- data/lib/stamina/sample.rb +0 -267
- data/lib/stamina/scoring.rb +0 -213
- data/lib/stamina/utils.rb +0 -1
- data/lib/stamina/utils/decorate.rb +0 -81
- data/lib/stamina/version.rb +0 -14
- data/stamina.gemspec +0 -191
- data/stamina.noespec +0 -32
- data/tasks/debug_mail.rake +0 -78
- data/tasks/debug_mail.txt +0 -13
- data/tasks/gem.rake +0 -68
- data/tasks/spec_test.rake +0 -79
- data/tasks/unit_test.rake +0 -77
- data/tasks/yard.rake +0 -51
- data/test/stamina/abbadingo/random_dfa_test.rb +0 -16
- data/test/stamina/abbadingo/random_sample_test.rb +0 -78
- data/test/stamina/adl_test.rb +0 -516
- data/test/stamina/automaton/classifier_test.rb +0 -259
- data/test/stamina/automaton/complete_test.rb +0 -58
- data/test/stamina/automaton/equivalence_test.rb +0 -120
- data/test/stamina/automaton/metrics_test.rb +0 -36
- data/test/stamina/automaton/minimize/hopcroft_test.rb +0 -15
- data/test/stamina/automaton/minimize/minimize_test.rb +0 -55
- data/test/stamina/automaton/minimize/pitchies_test.rb +0 -15
- data/test/stamina/automaton/minimize/rice_edu_10.adl +0 -16
- data/test/stamina/automaton/minimize/rice_edu_10.min.adl +0 -13
- data/test/stamina/automaton/minimize/rice_edu_13.adl +0 -13
- data/test/stamina/automaton/minimize/rice_edu_13.min.adl +0 -7
- data/test/stamina/automaton/minimize/should_strip_1.adl +0 -8
- data/test/stamina/automaton/minimize/should_strip_1.min.adl +0 -6
- data/test/stamina/automaton/minimize/unknown_1.adl +0 -16
- data/test/stamina/automaton/minimize/unknown_1.min.adl +0 -12
- data/test/stamina/automaton/strip_test.rb +0 -36
- data/test/stamina/automaton/to_dot_test.rb +0 -64
- data/test/stamina/automaton/walking/dfa_delta_test.rb +0 -39
- data/test/stamina/automaton/walking_test.rb +0 -206
- data/test/stamina/automaton_additional_test.rb +0 -190
- data/test/stamina/automaton_test.rb +0 -1104
- data/test/stamina/exit.rb +0 -3
- data/test/stamina/induction/blue_fringe_test.rb +0 -83
- data/test/stamina/induction/induction_test.rb +0 -70
- data/test/stamina/induction/redblue_mergesamestatebug_expected.adl +0 -19
- data/test/stamina/induction/redblue_mergesamestatebug_pta.dot +0 -64
- data/test/stamina/induction/redblue_mergesamestatebug_sample.adl +0 -9
- data/test/stamina/induction/redblue_universal_expected.adl +0 -4
- data/test/stamina/induction/redblue_universal_sample.adl +0 -5
- data/test/stamina/induction/rpni_inria_expected.adl +0 -7
- data/test/stamina/induction/rpni_inria_sample.adl +0 -9
- data/test/stamina/induction/rpni_test.rb +0 -129
- data/test/stamina/induction/rpni_test_pta.dot +0 -22
- data/test/stamina/induction/rpni_universal_expected.adl +0 -4
- data/test/stamina/induction/rpni_universal_sample.adl +0 -4
- data/test/stamina/induction/union_find_test.rb +0 -124
- data/test/stamina/input_string_test.rb +0 -323
- data/test/stamina/markable_test.rb +0 -70
- data/test/stamina/randdfa.adl +0 -66
- data/test/stamina/sample.adl +0 -4
- data/test/stamina/sample_classify_test.rb +0 -149
- data/test/stamina/sample_test.rb +0 -290
- data/test/stamina/scoring_test.rb +0 -63
- data/test/stamina/small_dfa.dot +0 -16
- data/test/stamina/small_dfa.gif +0 -0
- data/test/stamina/small_nfa.dot +0 -18
- data/test/stamina/small_nfa.gif +0 -0
- data/test/stamina/stamina_test.rb +0 -80
- data/test/stamina/utils/decorate_test.rb +0 -65
- data/test/test_all.rb +0 -7
data/test/stamina/exit.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "induction_test")
|
2
|
-
module Stamina
|
3
|
-
module Induction
|
4
|
-
class BlueFringeTest < Stamina::Induction::InductionTest
|
5
|
-
|
6
|
-
# Factors a ready to be tested BlueFringe instance
|
7
|
-
def blue_fringe(ufds)
|
8
|
-
blue_fringe = Stamina::Induction::BlueFringe.new(:verbose => false)
|
9
|
-
blue_fringe.instance_eval do
|
10
|
-
@ufds = ufds
|
11
|
-
end
|
12
|
-
blue_fringe
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_merge_and_determinize_score
|
16
|
-
blue_fringe = blue_fringe(factor_ufds)
|
17
|
-
assert_equal nil, blue_fringe.merge_and_determinize_score(1, 0)
|
18
|
-
assert_equal 1, blue_fringe.merge_and_determinize_score(1, 3)
|
19
|
-
assert_equal 1, blue_fringe.merge_and_determinize_score(2, 0)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_main_whole_execution
|
23
|
-
ufds = factor_ufds
|
24
|
-
blue_fringe = blue_fringe(ufds)
|
25
|
-
assert_equal [0, 1, 0, 1, 0, 1, 0, 0, 1, 0], blue_fringe.main(ufds).to_a
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_execute_whole_execution
|
29
|
-
expected = Stamina::ADL.parse_automaton <<-EOF
|
30
|
-
2 4
|
31
|
-
0 true true
|
32
|
-
1 false false
|
33
|
-
0 0 b
|
34
|
-
0 1 a
|
35
|
-
1 0 b
|
36
|
-
1 1 a
|
37
|
-
EOF
|
38
|
-
dfa = BlueFringe.execute(@sample)
|
39
|
-
assert_equal true, @sample.correctly_classified_by?(dfa)
|
40
|
-
assert_equal @sample.signature, dfa.signature(@sample)
|
41
|
-
assert_nil equivalent?(expected, dfa)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_on_dedicated_examples
|
45
|
-
here = File.dirname(__FILE__)
|
46
|
-
Dir["#{here}/redblue_*_sample.adl"].each do |sample_file|
|
47
|
-
name = (/^redblue_(.*?)_sample.adl$/.match(File.basename(sample_file)))[1]
|
48
|
-
sample = Stamina::ADL.parse_sample_file(sample_file)
|
49
|
-
expected = Stamina::ADL.parse_automaton_file(File.join(here, "redblue_#{name}_expected.adl"))
|
50
|
-
assert sample.correctly_classified_by?(expected)
|
51
|
-
dfa = BlueFringe.execute(sample)
|
52
|
-
assert sample.correctly_classified_by?(dfa)
|
53
|
-
assert_equal sample.signature, dfa.signature(sample)
|
54
|
-
assert_nil equivalent?(expected, dfa)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Tests on characteristic sample
|
59
|
-
def test_on_public_characteristic_example
|
60
|
-
example_folder = File.join(File.dirname(__FILE__), '..', '..', '..', 'example', 'basic')
|
61
|
-
sample = Stamina::ADL.parse_sample_file(File.join(example_folder, 'characteristic_sample.adl'))
|
62
|
-
blue_fringed = Stamina::Induction::BlueFringe.execute(sample)
|
63
|
-
assert_equal 4, blue_fringed.state_count
|
64
|
-
s0, = blue_fringed.initial_state
|
65
|
-
s1 = blue_fringed.dfa_step(s0, 'b')
|
66
|
-
s2 = blue_fringed.dfa_step(s0, 'a')
|
67
|
-
s3 = blue_fringed.dfa_step(s2, 'b')
|
68
|
-
assert_equal true, s0.accepting?
|
69
|
-
assert_equal true, s3.accepting?
|
70
|
-
assert_equal false, s1.accepting?
|
71
|
-
assert_equal false, s2.accepting?
|
72
|
-
assert_equal s1, s1.dfa_step('a')
|
73
|
-
assert_equal s1, s1.dfa_step('b')
|
74
|
-
assert_equal s2, s2.dfa_step('a')
|
75
|
-
assert_equal s3, s2.dfa_step('b')
|
76
|
-
assert_equal s3, s3.dfa_step('b')
|
77
|
-
assert_equal s0, s3.dfa_step('a')
|
78
|
-
assert_equal sample.signature, blue_fringed.signature(sample)
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'stamina'
|
3
|
-
require 'stamina/induction/union_find'
|
4
|
-
require 'stamina/induction/commons'
|
5
|
-
module Stamina
|
6
|
-
module Induction
|
7
|
-
class InductionTest < Test::Unit::TestCase
|
8
|
-
include Stamina::Induction::Commons
|
9
|
-
|
10
|
-
# Asserts that two states are equivalent and recurse.
|
11
|
-
def equivalent_states!(s1, s2, equivalences)
|
12
|
-
return "#{s1.index} and #{s2.index} don't agree on flags" \
|
13
|
-
unless s1.initial? == s2.initial? \
|
14
|
-
and s1.accepting? == s2.accepting? \
|
15
|
-
and s1.error? == s2.error?
|
16
|
-
return "#{s1.index} and #{s2.index} don't agree on out symbols #{s1.out_symbols.inspect} #{s2.out_symbols.inspect}"\
|
17
|
-
unless s1.out_symbols.sort == s2.out_symbols.sort
|
18
|
-
equivalences[s1.index] = s2.index
|
19
|
-
s1.out_symbols.each do |symbol|
|
20
|
-
s1_target = s1.dfa_step(symbol)
|
21
|
-
s2_target = s2.dfa_step(symbol)
|
22
|
-
return false if (s1_target.nil? or s2_target.nil?)
|
23
|
-
if equivalences.has_key?(s1_target.index)
|
24
|
-
return "#{s1.index} and #{s2.index} don't agree on #{symbol}"\
|
25
|
-
unless equivalences[s1_target.index]==s2_target.index
|
26
|
-
else
|
27
|
-
return msg \
|
28
|
-
if msg=equivalent_states!(s1_target, s2_target, equivalences)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
nil
|
32
|
-
end
|
33
|
-
|
34
|
-
# Checks if two DFAs are equivalent.
|
35
|
-
def equivalent?(dfa1, dfa2)
|
36
|
-
return "not same number of states" unless dfa1.state_count==dfa2.state_count
|
37
|
-
equivalent_states!(dfa1.initial_state, dfa2.initial_state, {})
|
38
|
-
end
|
39
|
-
|
40
|
-
# Puts a PTA under @pta
|
41
|
-
def setup
|
42
|
-
@sample = Stamina::ADL.parse_sample <<-EOF
|
43
|
-
+
|
44
|
-
- a
|
45
|
-
- a a
|
46
|
-
+ a b
|
47
|
-
- b a b a
|
48
|
-
+ b a b b
|
49
|
-
+ b b
|
50
|
-
EOF
|
51
|
-
@pta = sample2pta(@sample)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Returns index-th state of the PTA
|
55
|
-
def s(index)
|
56
|
-
@pta.ith_state(index)
|
57
|
-
end
|
58
|
-
|
59
|
-
# Factors a UnionFind instance from the PTA under @pta.
|
60
|
-
def factor_ufds
|
61
|
-
pta2ufds(@pta)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Just to avoid a stupid ruby error on empty test units.
|
65
|
-
def test_empty
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end # module Induction
|
70
|
-
end # module Stamina
|
@@ -1,64 +0,0 @@
|
|
1
|
-
digraph G {
|
2
|
-
graph [rankdir="LR"];
|
3
|
-
0 [color="black" fillcolor="green" shape="circle" style="filled"];
|
4
|
-
1 [color="black" fillcolor="white" shape="doublecircle" style="filled"];
|
5
|
-
2 [color="black" fillcolor="white" shape="circle" style="filled"];
|
6
|
-
3 [color="black" fillcolor="white" shape="circle" style="filled"];
|
7
|
-
4 [color="black" fillcolor="white" shape="circle" style="filled"];
|
8
|
-
5 [color="black" fillcolor="white" shape="circle" style="filled"];
|
9
|
-
6 [color="black" fillcolor="white" shape="circle" style="filled"];
|
10
|
-
7 [color="black" fillcolor="white" shape="circle" style="filled"];
|
11
|
-
8 [color="black" fillcolor="white" shape="circle" style="filled"];
|
12
|
-
9 [color="black" fillcolor="white" shape="circle" style="filled"];
|
13
|
-
10 [color="black" fillcolor="white" shape="circle" style="filled"];
|
14
|
-
11 [color="black" fillcolor="white" shape="circle" style="filled"];
|
15
|
-
12 [color="black" fillcolor="red" shape="circle" style="filled"];
|
16
|
-
13 [color="black" fillcolor="white" shape="circle" style="filled"];
|
17
|
-
14 [color="black" fillcolor="white" shape="circle" style="filled"];
|
18
|
-
15 [color="black" fillcolor="red" shape="circle" style="filled"];
|
19
|
-
16 [color="black" fillcolor="red" shape="circle" style="filled"];
|
20
|
-
17 [color="black" fillcolor="white" shape="circle" style="filled"];
|
21
|
-
18 [color="black" fillcolor="red" shape="circle" style="filled"];
|
22
|
-
19 [color="black" fillcolor="white" shape="doublecircle" style="filled"];
|
23
|
-
20 [color="black" fillcolor="white" shape="circle" style="filled"];
|
24
|
-
21 [color="black" fillcolor="white" shape="circle" style="filled"];
|
25
|
-
22 [color="black" fillcolor="white" shape="doublecircle" style="filled"];
|
26
|
-
23 [color="black" fillcolor="white" shape="circle" style="filled"];
|
27
|
-
24 [color="black" fillcolor="white" shape="circle" style="filled"];
|
28
|
-
25 [color="black" fillcolor="white" shape="circle" style="filled"];
|
29
|
-
26 [color="black" fillcolor="white" shape="circle" style="filled"];
|
30
|
-
27 [color="black" fillcolor="white" shape="doublecircle" style="filled"];
|
31
|
-
28 [color="black" fillcolor="white" shape="circle" style="filled"];
|
32
|
-
29 [color="black" fillcolor="white" shape="circle" style="filled"];
|
33
|
-
30 [color="black" fillcolor="white" shape="doublecircle" style="filled"];
|
34
|
-
0 -> 2 [label="1"];
|
35
|
-
2 -> 4 [label="1"];
|
36
|
-
4 -> 7 [label="1"];
|
37
|
-
7 -> 11 [label="1"];
|
38
|
-
11 -> 15 [label="0"];
|
39
|
-
0 -> 1 [label="0"];
|
40
|
-
1 -> 3 [label="0"];
|
41
|
-
3 -> 6 [label="1"];
|
42
|
-
6 -> 10 [label="1"];
|
43
|
-
10 -> 14 [label="0"];
|
44
|
-
14 -> 18 [label="1"];
|
45
|
-
18 -> 20 [label="0"];
|
46
|
-
20 -> 22 [label="1"];
|
47
|
-
18 -> 21 [label="1"];
|
48
|
-
21 -> 23 [label="0"];
|
49
|
-
23 -> 24 [label="0"];
|
50
|
-
24 -> 26 [label="1"];
|
51
|
-
26 -> 28 [label="1"];
|
52
|
-
28 -> 29 [label="0"];
|
53
|
-
29 -> 30 [label="1"];
|
54
|
-
24 -> 25 [label="0"];
|
55
|
-
25 -> 27 [label="0"];
|
56
|
-
14 -> 17 [label="0"];
|
57
|
-
17 -> 19 [label="1"];
|
58
|
-
6 -> 9 [label="0"];
|
59
|
-
9 -> 13 [label="0"];
|
60
|
-
13 -> 16 [label="1"];
|
61
|
-
3 -> 5 [label="0"];
|
62
|
-
5 -> 8 [label="0"];
|
63
|
-
8 -> 12 [label="0"];
|
64
|
-
}
|
@@ -1,129 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "induction_test")
|
2
|
-
module Stamina
|
3
|
-
module Induction
|
4
|
-
class RPNITest < Stamina::Induction::InductionTest
|
5
|
-
include Stamina::Induction::Commons
|
6
|
-
|
7
|
-
# Factors a ready to be used RPNI instance with an initial UnionFind.
|
8
|
-
def rpni(ufds)
|
9
|
-
rpni = RPNI.new(:verbose => false)
|
10
|
-
rpni.instance_eval do
|
11
|
-
@ufds = ufds
|
12
|
-
end
|
13
|
-
rpni
|
14
|
-
end
|
15
|
-
|
16
|
-
# Returns index-th state of the PTA
|
17
|
-
def s(index)
|
18
|
-
@pta.ith_state(index)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_compatible_merge_and_determinize_without_determinize
|
22
|
-
rpni = rpni(factor_ufds)
|
23
|
-
assert_equal true, rpni.merge_and_determinize(0, 4)
|
24
|
-
assert_equal [0, 1, 2, 3, 0, 5, 6, 7, 8, 9], rpni.ufds.to_a
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_compatible_merge_and_determinize_with_one_determinize
|
28
|
-
rpni = rpni(factor_ufds)
|
29
|
-
assert_equal true, rpni.merge_and_determinize(2, 7)
|
30
|
-
assert_equal [0, 1, 2, 3, 4, 5, 6, 2, 5, 6], rpni.ufds.to_a
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_incompatible_merge_and_determinize_without_determinize
|
34
|
-
rpni = rpni(factor_ufds)
|
35
|
-
assert_equal false, rpni.merge_and_determinize(0, 1)
|
36
|
-
assert_equal [0, 0, 2, 3, 4, 5, 6, 7, 8, 9], rpni.ufds.to_a
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_incompatible_merge_and_determinize_with_two_determinize
|
40
|
-
rpni = rpni(factor_ufds)
|
41
|
-
assert_equal false, rpni.merge_and_determinize(5, 0)
|
42
|
-
assert_equal [0, 1, 2, 3, 4, 0, 6, 2, 0, 9], rpni.ufds.to_a
|
43
|
-
end
|
44
|
-
|
45
|
-
def execution_step(rpni, i, j, success, expected=nil)
|
46
|
-
before = rpni.ufds.to_a
|
47
|
-
assert_equal success, rpni.successfull_merge_or_nothing(i, j)
|
48
|
-
if success
|
49
|
-
assert_equal(expected, rpni.ufds.to_a) if expected
|
50
|
-
else
|
51
|
-
assert_equal before, rpni.ufds.to_a
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_step_by_step_whole_execution
|
56
|
-
rpni = rpni(factor_ufds)
|
57
|
-
execution_step(rpni,1,0,false)
|
58
|
-
execution_step(rpni,2,0,true,[0, 1, 0, 3, 4, 1, 0, 4, 8, 9])
|
59
|
-
execution_step(rpni,3,0,false)
|
60
|
-
execution_step(rpni,3,1,true,[0, 1, 0, 1, 4, 1, 0, 4, 8, 9])
|
61
|
-
execution_step(rpni,4,0,true,[0, 1, 0, 1, 0, 1, 0, 0, 1, 0])
|
62
|
-
|
63
|
-
ufds = factor_ufds
|
64
|
-
rpni = rpni(ufds)
|
65
|
-
assert_equal [0, 1, 0, 1, 0, 1, 0, 0, 1, 0], rpni.main(ufds).to_a
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_main_whole_execution
|
69
|
-
ufds = factor_ufds
|
70
|
-
rpni = rpni(ufds)
|
71
|
-
assert_equal [0, 1, 0, 1, 0, 1, 0, 0, 1, 0], rpni.main(ufds).to_a
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_execute_whole_execution
|
75
|
-
expected = Stamina::ADL.parse_automaton <<-EOF
|
76
|
-
2 4
|
77
|
-
0 true true
|
78
|
-
1 false false
|
79
|
-
0 0 b
|
80
|
-
0 1 a
|
81
|
-
1 0 b
|
82
|
-
1 1 a
|
83
|
-
EOF
|
84
|
-
dfa = RPNI.execute(@sample)
|
85
|
-
assert_equal true, @sample.correctly_classified_by?(dfa)
|
86
|
-
assert_equal @sample.signature, dfa.signature(@sample)
|
87
|
-
assert_nil equivalent?(expected, dfa)
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_on_dedicated_examples
|
91
|
-
here = File.dirname(__FILE__)
|
92
|
-
Dir["#{here}/rpni_*_sample.adl"].each do |sample_file|
|
93
|
-
name = (/^rpni_(.*?)_sample.adl$/.match(File.basename(sample_file)))[1]
|
94
|
-
sample = Stamina::ADL.parse_sample_file(sample_file)
|
95
|
-
expected = Stamina::ADL.parse_automaton_file(File.join(here, "rpni_#{name}_expected.adl"))
|
96
|
-
assert sample.correctly_classified_by?(expected)
|
97
|
-
dfa = RPNI.execute(sample)
|
98
|
-
assert sample.correctly_classified_by?(dfa)
|
99
|
-
assert_equal sample.signature, dfa.signature(sample)
|
100
|
-
assert_nil equivalent?(expected, dfa)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Tests on characteristic sample
|
105
|
-
def test_on_public_characteristic_example
|
106
|
-
example_folder = File.join(File.dirname(__FILE__), '..', '..', '..', 'example', 'basic')
|
107
|
-
sample = Stamina::ADL.parse_sample_file(File.join(example_folder, 'characteristic_sample.adl'))
|
108
|
-
rpnied = Stamina::Induction::RPNI.execute(sample)
|
109
|
-
assert_equal 4, rpnied.state_count
|
110
|
-
s0, = rpnied.initial_state
|
111
|
-
s1 = rpnied.dfa_step(s0, 'b')
|
112
|
-
s2 = rpnied.dfa_step(s0, 'a')
|
113
|
-
s3 = rpnied.dfa_step(s2, 'b')
|
114
|
-
assert_equal true, s0.accepting?
|
115
|
-
assert_equal true, s3.accepting?
|
116
|
-
assert_equal false, s1.accepting?
|
117
|
-
assert_equal false, s2.accepting?
|
118
|
-
assert_equal s1, s1.dfa_step('a')
|
119
|
-
assert_equal s1, s1.dfa_step('b')
|
120
|
-
assert_equal s2, s2.dfa_step('a')
|
121
|
-
assert_equal s3, s2.dfa_step('b')
|
122
|
-
assert_equal s3, s3.dfa_step('b')
|
123
|
-
assert_equal s0, s3.dfa_step('a')
|
124
|
-
assert_equal sample.signature, rpnied.signature(sample)
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
digraph G {
|
2
|
-
graph [rankdir="LR"];
|
3
|
-
0 [color="green" shape="doublecircle" style="filled"];
|
4
|
-
1 [color="red" shape="circle" style="filled"];
|
5
|
-
2 [color="black" shape="circle" style="filled" fillcolor="white"];
|
6
|
-
3 [color="red" shape="circle" style="filled"];
|
7
|
-
4 [color="black" shape="doublecircle" style="filled" fillcolor="white"];
|
8
|
-
5 [color="black" shape="circle" style="filled" fillcolor="white"];
|
9
|
-
6 [color="black" shape="doublecircle" style="filled" fillcolor="white"];
|
10
|
-
7 [color="black" shape="circle" style="filled" fillcolor="white"];
|
11
|
-
8 [color="red" shape="circle" style="filled"];
|
12
|
-
9 [color="black" shape="doublecircle" style="filled" fillcolor="white"];
|
13
|
-
0 -> 1 [label="a"];
|
14
|
-
1 -> 3 [label="a"];
|
15
|
-
1 -> 4 [label="b"];
|
16
|
-
0 -> 2 [label="b"];
|
17
|
-
2 -> 5 [label="a"];
|
18
|
-
5 -> 7 [label="b"];
|
19
|
-
7 -> 8 [label="a"];
|
20
|
-
7 -> 9 [label="b"];
|
21
|
-
2 -> 6 [label="b"];
|
22
|
-
}
|