sequitur 0.0.07 → 0.0.08
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +3 -0
- data/lib/sequitur/constants.rb +1 -1
- data/lib/sequitur/digram.rb +1 -1
- data/lib/sequitur/production.rb +4 -2
- data/spec/sequitur/production_spec.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODkxZDczYzdhYTJhMTk5NzU1MGUzNTZjZWEyZjNlODI5YzRhOGY2Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTA2NjA5ZGRhZDI4YjA3ZmJhOWQwNmM2ODMwYTFlZmYxOTcxMzYzNg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDJmMDQwYjMxYWI4YzhiZmRmM2IzMjM1ZGM0OGFiNzE0YzI0ZDRhNzNmNTM3
|
10
|
+
N2ExNzNhMTI0ODM3NzcwNDQxY2UxYjJhMzk1NmMwYTcyZDAyMzZkYzZkMDFk
|
11
|
+
MjgwYmQ0ZjdhOTJkNzcxMTRhNjJkYTE3ZTQyZDAzMDg5M2M3MzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODUwZjc1NDhlNWI1YmQyNjY0ODRlNmZhMTdmMTEzMGEyYzEyYjVmNjk2MWQy
|
14
|
+
MjlmMjQ2NjQ0NmJmZTcyNzM4OTUzMTgxZTE2YzkwOTY4ZGYwZTNmZjNiMmRm
|
15
|
+
MTk3NzRiNDA1NzJjOTAzNDFiOTI1NmZhZmJmZDRkODA2NThjOGY=
|
data/CHANGELOG.md
CHANGED
data/lib/sequitur/constants.rb
CHANGED
data/lib/sequitur/digram.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Sequitur # Module for classes implementing the Sequitur algorithm
|
4
4
|
|
5
|
-
# In
|
5
|
+
# In linguistics, a digram is a sequence of two letters.
|
6
6
|
# In Sequitur a digram is a sequence of two consecutive symbols that
|
7
7
|
# appear in a grammar (production) rule. Each symbol in a digram
|
8
8
|
# can be a terminal or not.
|
data/lib/sequitur/production.rb
CHANGED
@@ -35,7 +35,7 @@ class Production
|
|
35
35
|
end
|
36
36
|
|
37
37
|
|
38
|
-
# Return the set of productions appearing in the rhs
|
38
|
+
# Return the set of productions appearing in the rhs.
|
39
39
|
def references()
|
40
40
|
return rhs.select { |symb| symb.kind_of?(Production) }
|
41
41
|
end
|
@@ -80,6 +80,8 @@ class Production
|
|
80
80
|
end
|
81
81
|
|
82
82
|
# Add a back reference to the given production.
|
83
|
+
# @param aProduction [Production] Assume that production P appears in the
|
84
|
+
# RHS of production Q, then a reference count of P is incremented in Q.
|
83
85
|
def add_backref(aProduction)
|
84
86
|
prod_id = aProduction.object_id
|
85
87
|
|
@@ -113,7 +115,7 @@ class Production
|
|
113
115
|
case elem
|
114
116
|
when String then "'#{elem}'"
|
115
117
|
when Production then "#{elem.object_id}"
|
116
|
-
else
|
118
|
+
else elem.to_s
|
117
119
|
end
|
118
120
|
end
|
119
121
|
|
@@ -125,9 +125,10 @@ describe Production do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'should emit its text representation' do
|
128
|
-
|
128
|
+
instance = Production.new
|
129
|
+
symbols = [:a, :b, 'c', :d, :e, 1000, instance]
|
129
130
|
symbols.each { |symb| subject.append_symbol(symb) }
|
130
|
-
expectation = "#{subject.object_id} : a b 'c' d e
|
131
|
+
expectation = "#{subject.object_id} : a b 'c' d e 1000 #{instance.object_id}."
|
131
132
|
expect(subject.to_string).to eq(expectation)
|
132
133
|
end
|
133
134
|
|