stamina 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/.gemtest +0 -0
  2. data/CHANGELOG.md +22 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +33 -0
  5. data/LICENCE.md +22 -0
  6. data/Manifest.txt +16 -0
  7. data/README.md +78 -0
  8. data/Rakefile +23 -0
  9. data/bin/adl2dot +12 -0
  10. data/bin/classify +12 -0
  11. data/bin/redblue +12 -0
  12. data/bin/rpni +12 -0
  13. data/example/adl/automaton.adl +49 -0
  14. data/example/adl/sample.adl +53 -0
  15. data/example/basic/characteristic_sample.adl +32 -0
  16. data/example/basic/target.adl +9 -0
  17. data/example/competition/31_test.adl +1500 -0
  18. data/example/competition/31_training.adl +1759 -0
  19. data/lib/stamina.rb +19 -0
  20. data/lib/stamina/adl.rb +298 -0
  21. data/lib/stamina/automaton.rb +1237 -0
  22. data/lib/stamina/automaton/walking.rb +336 -0
  23. data/lib/stamina/classifier.rb +37 -0
  24. data/lib/stamina/command/adl2dot_command.rb +73 -0
  25. data/lib/stamina/command/classify_command.rb +57 -0
  26. data/lib/stamina/command/redblue_command.rb +58 -0
  27. data/lib/stamina/command/rpni_command.rb +58 -0
  28. data/lib/stamina/command/stamina_command.rb +79 -0
  29. data/lib/stamina/errors.rb +20 -0
  30. data/lib/stamina/induction/commons.rb +170 -0
  31. data/lib/stamina/induction/redblue.rb +264 -0
  32. data/lib/stamina/induction/rpni.rb +188 -0
  33. data/lib/stamina/induction/union_find.rb +377 -0
  34. data/lib/stamina/input_string.rb +123 -0
  35. data/lib/stamina/loader.rb +0 -0
  36. data/lib/stamina/markable.rb +42 -0
  37. data/lib/stamina/sample.rb +190 -0
  38. data/lib/stamina/version.rb +14 -0
  39. data/stamina.gemspec +190 -0
  40. data/stamina.noespec +35 -0
  41. data/tasks/debug_mail.rake +78 -0
  42. data/tasks/debug_mail.txt +13 -0
  43. data/tasks/gem.rake +68 -0
  44. data/tasks/spec_test.rake +79 -0
  45. data/tasks/unit_test.rake +77 -0
  46. data/tasks/yard.rake +51 -0
  47. data/test/stamina/adl_test.rb +491 -0
  48. data/test/stamina/automaton_additional_test.rb +190 -0
  49. data/test/stamina/automaton_classifier_test.rb +155 -0
  50. data/test/stamina/automaton_test.rb +1092 -0
  51. data/test/stamina/automaton_to_dot_test.rb +64 -0
  52. data/test/stamina/automaton_walking_test.rb +206 -0
  53. data/test/stamina/exit.rb +3 -0
  54. data/test/stamina/induction/induction_test.rb +70 -0
  55. data/test/stamina/induction/redblue_mergesamestatebug_expected.adl +19 -0
  56. data/test/stamina/induction/redblue_mergesamestatebug_pta.dot +64 -0
  57. data/test/stamina/induction/redblue_mergesamestatebug_sample.adl +9 -0
  58. data/test/stamina/induction/redblue_test.rb +83 -0
  59. data/test/stamina/induction/redblue_universal_expected.adl +4 -0
  60. data/test/stamina/induction/redblue_universal_sample.adl +5 -0
  61. data/test/stamina/induction/rpni_inria_expected.adl +7 -0
  62. data/test/stamina/induction/rpni_inria_sample.adl +9 -0
  63. data/test/stamina/induction/rpni_test.rb +129 -0
  64. data/test/stamina/induction/rpni_test_pta.dot +22 -0
  65. data/test/stamina/induction/rpni_universal_expected.adl +4 -0
  66. data/test/stamina/induction/rpni_universal_sample.adl +4 -0
  67. data/test/stamina/induction/union_find_test.rb +124 -0
  68. data/test/stamina/input_string_test.rb +323 -0
  69. data/test/stamina/markable_test.rb +70 -0
  70. data/test/stamina/randdfa.adl +66 -0
  71. data/test/stamina/sample.adl +4 -0
  72. data/test/stamina/sample_classify_test.rb +149 -0
  73. data/test/stamina/sample_test.rb +218 -0
  74. data/test/stamina/small_dfa.dot +16 -0
  75. data/test/stamina/small_dfa.gif +0 -0
  76. data/test/stamina/small_nfa.dot +18 -0
  77. data/test/stamina/small_nfa.gif +0 -0
  78. data/test/stamina/stamina_test.rb +69 -0
  79. data/test/test_all.rb +7 -0
  80. metadata +279 -0
@@ -0,0 +1,16 @@
1
+ digraph small_dfa {
2
+ graph [rankdir="LR"];
3
+ node [shape="circle"];
4
+ zz [label="" width=0.01 height=0.01];
5
+ 0 [shape=doublecircle label="s0"];
6
+ 1 [label="s1"];
7
+ 2 [shape=doublecircle label="s2"];
8
+ 3 [label="s3"];
9
+ 0 -> 1 [label="e0/a"]
10
+ 1 -> 2 [label="e1/b"]
11
+ 1 -> 3 [label="e2/a"]
12
+ 3 -> 2 [label="e3/b"]
13
+ 2 -> 0 [label="e4/c"]
14
+ 1 -> 1 [label="e5/c"]
15
+ zz -> 3 [label=""]
16
+ }
@@ -0,0 +1,18 @@
1
+ digraph small_nfa {
2
+ graph [rankdir="LR"];
3
+ node [shape="circle"];
4
+ zz [label="" width=0.01 height=0.01];
5
+ 0 [shape=doublecircle label="s0"];
6
+ 1 [label="s1"];
7
+ 2 [shape=doublecircle label="s2"];
8
+ 3 [label="s3"];
9
+ 0 -> 1 [label="e0/a"]
10
+ 1 -> 1 [label="e1/nil"]
11
+ 1 -> 2 [label="e2/b"]
12
+ 1 -> 3 [label="e3/b"]
13
+ 2 -> 3 [label="e4/c"]
14
+ 3 -> 0 [label="e5/a"]
15
+ 2 -> 1 [label="e6/nil"]
16
+ zz -> 0 [label=""]
17
+ zz -> 3 [label=""]
18
+ }
@@ -0,0 +1,69 @@
1
+ require 'test/unit'
2
+ require 'stamina'
3
+ module Stamina
4
+
5
+ #
6
+ # Main test class for stamina. By default this test installs default example
7
+ # automata on setup.
8
+ #
9
+ # In particular, it installs the following automata:
10
+ # - @small_dfa: a small deterministic automaton whose picture can be found in
11
+ # small_dfa.gif
12
+ # - @small_nfa: a small non deterministic automaton whose picture can be found
13
+ # in small_nfa.gif
14
+ #
15
+ # Moreover, is also provides the following helpers:
16
+ # - @examples is an array containing all created automata.
17
+ # - @dfa_examples is an array containing deterministic automaton only.
18
+ # - @nfa_examples is an array containing non-deterministic automaton only.
19
+ #
20
+ class StaminaTest < Test::Unit::TestCase
21
+
22
+ # Creates a small automaton for the sake of simple tests
23
+ def setup
24
+ @small_dfa = Automaton.new do
25
+ s0, s1, s2, s3 = add_n_states(4)
26
+ s3.initial!
27
+ s0.accepting!
28
+ s2.accepting!
29
+ connect(s0, s1, 'a')
30
+ connect(s1, s2, 'b')
31
+ connect(s1, s3, 'a')
32
+ connect(s3, s2, 'b')
33
+ connect(s2, s0, 'c')
34
+ connect(s1, s1, 'c')
35
+ end
36
+
37
+ @small_nfa = Automaton.new do
38
+ s0, s1, s2, s3 = add_n_states(4)
39
+ s0.initial!
40
+ s3.initial!
41
+ s0.accepting!
42
+ s2.accepting!
43
+ connect(s0, s1, 'a')
44
+ connect(s1, s1, nil)
45
+ connect(s1, s2, 'b')
46
+ connect(s1, s3, 'b')
47
+ connect(s2, s3, 'c')
48
+ connect(s3, s0, 'a')
49
+ connect(s2, s1, nil)
50
+ end
51
+
52
+ @examples = [@small_dfa, @small_nfa]
53
+ @dfa_examples = [@small_dfa]
54
+ @nfa_examples = [@small_nfa]
55
+ end
56
+
57
+ # Tests the validity of examples
58
+ def test_validity_of_examples
59
+ @dfa_examples.each do |e|
60
+ assert_equal(true, e.deterministic?)
61
+ end
62
+ @nfa_examples.each do |e|
63
+ assert_equal(false, e.deterministic?)
64
+ end
65
+ end
66
+
67
+ end # class StaminaTest
68
+
69
+ end # module Stamina
@@ -0,0 +1,7 @@
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..')
2
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
3
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'test')
4
+ test_files = Dir['**/*_test.rb']
5
+ test_files.each { |file|
6
+ require(file)
7
+ }
metadata ADDED
@@ -0,0 +1,279 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stamina
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
+ platform: ruby
12
+ authors:
13
+ - Bernard Lambeau
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-24 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :development
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 49
29
+ segments:
30
+ - 0
31
+ - 8
32
+ - 7
33
+ version: 0.8.7
34
+ name: rake
35
+ version_requirements: *id001
36
+ prerelease: false
37
+ - !ruby/object:Gem::Dependency
38
+ type: :development
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 15
45
+ segments:
46
+ - 1
47
+ - 0
48
+ version: "1.0"
49
+ name: bundler
50
+ version_requirements: *id002
51
+ prerelease: false
52
+ - !ruby/object:Gem::Dependency
53
+ type: :development
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 31
60
+ segments:
61
+ - 2
62
+ - 4
63
+ - 0
64
+ version: 2.4.0
65
+ name: rspec
66
+ version_requirements: *id003
67
+ prerelease: false
68
+ - !ruby/object:Gem::Dependency
69
+ type: :development
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ hash: 15
76
+ segments:
77
+ - 0
78
+ - 6
79
+ - 4
80
+ version: 0.6.4
81
+ name: yard
82
+ version_requirements: *id004
83
+ prerelease: false
84
+ - !ruby/object:Gem::Dependency
85
+ type: :development
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ hash: 29
92
+ segments:
93
+ - 2
94
+ - 0
95
+ - 9
96
+ version: 2.0.9
97
+ name: bluecloth
98
+ version_requirements: *id005
99
+ prerelease: false
100
+ - !ruby/object:Gem::Dependency
101
+ type: :development
102
+ requirement: &id006 !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ~>
106
+ - !ruby/object:Gem::Version
107
+ hash: 53
108
+ segments:
109
+ - 0
110
+ - 10
111
+ - 1
112
+ version: 0.10.1
113
+ name: wlang
114
+ version_requirements: *id006
115
+ prerelease: false
116
+ description: |-
117
+ Stamina is an automaton and regular inference toolkit initially developped for the baseline
118
+ of the Stamina Competition (stamina.chefbe.net).
119
+ email:
120
+ - blambeau@gmail.com
121
+ executables:
122
+ - adl2dot
123
+ - classify
124
+ - redblue
125
+ - rpni
126
+ extensions: []
127
+
128
+ extra_rdoc_files:
129
+ - README.md
130
+ - CHANGELOG.md
131
+ - LICENCE.md
132
+ files:
133
+ - bin/adl2dot
134
+ - bin/classify
135
+ - bin/redblue
136
+ - bin/rpni
137
+ - example/adl/automaton.adl
138
+ - example/adl/sample.adl
139
+ - example/basic/characteristic_sample.adl
140
+ - example/basic/target.adl
141
+ - example/competition/31_test.adl
142
+ - example/competition/31_training.adl
143
+ - lib/stamina.rb
144
+ - lib/stamina/adl.rb
145
+ - lib/stamina/automaton.rb
146
+ - lib/stamina/automaton/walking.rb
147
+ - lib/stamina/classifier.rb
148
+ - lib/stamina/command/adl2dot_command.rb
149
+ - lib/stamina/command/classify_command.rb
150
+ - lib/stamina/command/redblue_command.rb
151
+ - lib/stamina/command/rpni_command.rb
152
+ - lib/stamina/command/stamina_command.rb
153
+ - lib/stamina/errors.rb
154
+ - lib/stamina/induction/commons.rb
155
+ - lib/stamina/induction/redblue.rb
156
+ - lib/stamina/induction/rpni.rb
157
+ - lib/stamina/induction/union_find.rb
158
+ - lib/stamina/input_string.rb
159
+ - lib/stamina/markable.rb
160
+ - lib/stamina/sample.rb
161
+ - lib/stamina/version.rb
162
+ - lib/stamina/loader.rb
163
+ - tasks/yard.rake
164
+ - tasks/debug_mail.txt
165
+ - tasks/gem.rake
166
+ - tasks/unit_test.rake
167
+ - tasks/debug_mail.rake
168
+ - tasks/spec_test.rake
169
+ - test/stamina/adl_test.rb
170
+ - test/stamina/automaton_additional_test.rb
171
+ - test/stamina/automaton_classifier_test.rb
172
+ - test/stamina/automaton_test.rb
173
+ - test/stamina/automaton_to_dot_test.rb
174
+ - test/stamina/automaton_walking_test.rb
175
+ - test/stamina/exit.rb
176
+ - test/stamina/induction/induction_test.rb
177
+ - test/stamina/induction/redblue_mergesamestatebug_expected.adl
178
+ - test/stamina/induction/redblue_mergesamestatebug_pta.dot
179
+ - test/stamina/induction/redblue_mergesamestatebug_sample.adl
180
+ - test/stamina/induction/redblue_test.rb
181
+ - test/stamina/induction/redblue_universal_expected.adl
182
+ - test/stamina/induction/redblue_universal_sample.adl
183
+ - test/stamina/induction/rpni_inria_expected.adl
184
+ - test/stamina/induction/rpni_inria_sample.adl
185
+ - test/stamina/induction/rpni_test.rb
186
+ - test/stamina/induction/rpni_test_pta.dot
187
+ - test/stamina/induction/rpni_universal_expected.adl
188
+ - test/stamina/induction/rpni_universal_sample.adl
189
+ - test/stamina/induction/union_find_test.rb
190
+ - test/stamina/input_string_test.rb
191
+ - test/stamina/markable_test.rb
192
+ - test/stamina/randdfa.adl
193
+ - test/stamina/sample.adl
194
+ - test/stamina/sample_classify_test.rb
195
+ - test/stamina/sample_test.rb
196
+ - test/stamina/small_dfa.dot
197
+ - test/stamina/small_dfa.gif
198
+ - test/stamina/small_nfa.dot
199
+ - test/stamina/small_nfa.gif
200
+ - test/stamina/stamina_test.rb
201
+ - test/test_all.rb
202
+ - .gemtest
203
+ - CHANGELOG.md
204
+ - Gemfile
205
+ - Gemfile.lock
206
+ - LICENCE.md
207
+ - Manifest.txt
208
+ - Rakefile
209
+ - README.md
210
+ - stamina.gemspec
211
+ - stamina.noespec
212
+ has_rdoc: true
213
+ homepage: http://stamina.chefbe.net/
214
+ licenses: []
215
+
216
+ post_install_message:
217
+ rdoc_options: []
218
+
219
+ require_paths:
220
+ - lib
221
+ required_ruby_version: !ruby/object:Gem::Requirement
222
+ none: false
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ hash: 3
227
+ segments:
228
+ - 0
229
+ version: "0"
230
+ required_rubygems_version: !ruby/object:Gem::Requirement
231
+ none: false
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ hash: 3
236
+ segments:
237
+ - 0
238
+ version: "0"
239
+ requirements: []
240
+
241
+ rubyforge_project:
242
+ rubygems_version: 1.6.2
243
+ signing_key:
244
+ specification_version: 3
245
+ summary: Automaton and Regular Inference Toolkit
246
+ test_files:
247
+ - test/stamina/adl_test.rb
248
+ - test/stamina/automaton_additional_test.rb
249
+ - test/stamina/automaton_classifier_test.rb
250
+ - test/stamina/automaton_test.rb
251
+ - test/stamina/automaton_to_dot_test.rb
252
+ - test/stamina/automaton_walking_test.rb
253
+ - test/stamina/exit.rb
254
+ - test/stamina/induction/induction_test.rb
255
+ - test/stamina/induction/redblue_mergesamestatebug_expected.adl
256
+ - test/stamina/induction/redblue_mergesamestatebug_pta.dot
257
+ - test/stamina/induction/redblue_mergesamestatebug_sample.adl
258
+ - test/stamina/induction/redblue_test.rb
259
+ - test/stamina/induction/redblue_universal_expected.adl
260
+ - test/stamina/induction/redblue_universal_sample.adl
261
+ - test/stamina/induction/rpni_inria_expected.adl
262
+ - test/stamina/induction/rpni_inria_sample.adl
263
+ - test/stamina/induction/rpni_test.rb
264
+ - test/stamina/induction/rpni_test_pta.dot
265
+ - test/stamina/induction/rpni_universal_expected.adl
266
+ - test/stamina/induction/rpni_universal_sample.adl
267
+ - test/stamina/induction/union_find_test.rb
268
+ - test/stamina/input_string_test.rb
269
+ - test/stamina/markable_test.rb
270
+ - test/stamina/randdfa.adl
271
+ - test/stamina/sample.adl
272
+ - test/stamina/sample_classify_test.rb
273
+ - test/stamina/sample_test.rb
274
+ - test/stamina/small_dfa.dot
275
+ - test/stamina/small_dfa.gif
276
+ - test/stamina/small_nfa.dot
277
+ - test/stamina/small_nfa.gif
278
+ - test/stamina/stamina_test.rb
279
+ - test/test_all.rb