stamina-core 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ # 0.6.1 / 2012-10-16
2
+
3
+ * Fixed a bug in TransitionSystem::Equivalence that did not take non complete mapping into
4
+ account.
5
+ * Fixed a bug in Automaton#complete when the alphabet is empty.
6
+ * Fixed a bug in Automaton#to_dot when sort_states is false and no rewriter is passed.
7
+
1
8
  # 0.6.0 / 2012-09-12
2
9
 
3
10
  * Added Markable#marks and Markable#raw_data
@@ -863,7 +863,7 @@ module Stamina
863
863
  #
864
864
  def to_dot(sort_states = true, &rewriter)
865
865
  unless rewriter
866
- to_dot do |elm, kind|
866
+ to_dot(sort_states) do |elm, kind|
867
867
  case kind
868
868
  when :automaton
869
869
  {:pack => true, :rankdir => "LR", :ranksep => 0, :margin => 0}
@@ -28,7 +28,8 @@ module Stamina
28
28
  connect(s, sink, symbol)
29
29
  end
30
30
  end
31
- drop_state(sink) if sink.adjacent_states == [sink]
31
+ adj = sink.adjacent_states
32
+ drop_state(sink) if adj.empty? or adj == [sink]
32
33
  self
33
34
  end
34
35
 
@@ -63,7 +63,9 @@ module Stamina
63
63
  symbol = edge.symbol
64
64
  source = reference.ith_state(deco)
65
65
  eq_edge = algo.find_edge_counterpart(source, edge)
66
- algo.fail("No such transition `#{symbol}` from #{source}") unless eq_edge
66
+ unless eq_edge
67
+ algo.fail("No such transition `#{symbol}` from #{source}")
68
+ end
67
69
  algo.equivalent_edges!(edge, eq_edge)
68
70
  algo.equivalent_states!(edge.target, eq_edge.target)
69
71
  eq_edge.target.index
@@ -89,8 +91,9 @@ module Stamina
89
91
  fail "No initial state on ts1" unless i1
90
92
  fail "No initial state on ts2" unless i2
91
93
  equivalent_states!(i1, i2)
92
- EquivThroughDeco.new(ts2, self).call(ts1, {})
93
- return true
94
+ mapping = {}
95
+ EquivThroughDeco.new(ts2, self).call(ts1, mapping)
96
+ return !mapping.any?{|k,v| v.nil?}
94
97
  end
95
98
  return false
96
99
  ensure
@@ -1 +1,2 @@
1
- require_relative 'utils/decorate'
1
+ require_relative 'utils/decorate'
2
+ require_relative 'utils/aggregator'
@@ -0,0 +1,45 @@
1
+ module Stamina
2
+ module Utils
3
+ class Aggregator
4
+
5
+ def initialize
6
+ @functions = {}
7
+ @default = nil
8
+ yield(self) if block_given?
9
+ end
10
+ attr_reader :functions
11
+
12
+ def register(key, function = nil, &bl)
13
+ functions[key] = function || bl
14
+ end
15
+
16
+ def default(function = nil, &bl)
17
+ @default = function || bl
18
+ end
19
+
20
+ def ignore(key)
21
+ register(key, lambda{|v1,v2| throw :ignore })
22
+ end
23
+
24
+ def merge(t1, t2)
25
+ tuple = {}
26
+ t1.keys.each do |k|
27
+ next unless fn = functions[k] || @default
28
+ catch :ignore do
29
+ tuple[k] = fn.call(t1[k], t2[k])
30
+ end
31
+ end
32
+ tuple
33
+ end
34
+
35
+ def aggregate(enum)
36
+ memo = nil
37
+ enum.each do |tuple|
38
+ memo = memo ? merge(memo, tuple) : tuple
39
+ end
40
+ memo
41
+ end
42
+
43
+ end # class Aggregator
44
+ end # module Utils
45
+ end # module Stamina
@@ -3,7 +3,7 @@ module Stamina
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 6
6
- TINY = 0
6
+ TINY = 1
7
7
 
8
8
  def self.to_s
9
9
  [ MAJOR, MINOR, TINY ].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stamina-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-12 00:00:00.000000000 Z
12
+ date: 2012-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: quickl
16
- requirement: &70185698728600 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 0.4.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70185698728600
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.4.3
25
30
  description: ! "Stamina is an automaton and regular inference toolkit initially developped
26
31
  for the \nbaseline of the Stamina Competition (stamina.chefbe.net)."
27
32
  email:
@@ -66,6 +71,7 @@ files:
66
71
  - lib/stamina-core/stamina/sample.rb
67
72
  - lib/stamina-core/stamina/transition_system/equivalence.rb
68
73
  - lib/stamina-core/stamina/transition_system.rb
74
+ - lib/stamina-core/stamina/utils/aggregator.rb
69
75
  - lib/stamina-core/stamina/utils/decorate.rb
70
76
  - lib/stamina-core/stamina/utils.rb
71
77
  - lib/stamina-core/stamina/version.rb
@@ -82,9 +88,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
88
  - - ! '>='
83
89
  - !ruby/object:Gem::Version
84
90
  version: '0'
85
- segments:
86
- - 0
87
- hash: -57027985138010278
88
91
  required_rubygems_version: !ruby/object:Gem::Requirement
89
92
  none: false
90
93
  requirements:
@@ -93,8 +96,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
96
  version: '0'
94
97
  requirements: []
95
98
  rubyforge_project:
96
- rubygems_version: 1.8.15
99
+ rubygems_version: 1.8.24
97
100
  signing_key:
98
101
  specification_version: 3
99
102
  summary: Automaton and Regular Inference Toolkit
100
103
  test_files: []
104
+ has_rdoc: