sequitur 0.1.22 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -180
- data/CHANGELOG.md +11 -1
- data/LICENSE.txt +1 -1
- data/Rakefile +0 -2
- data/examples/integer_sample.rb +1 -2
- data/examples/porridge.rb +10 -10
- data/examples/simple_case.rb +1 -1
- data/examples/symbol_sample.rb +1 -1
- data/examples/word_sample.rb +5 -6
- data/lib/sequitur/constants.rb +5 -2
- data/lib/sequitur/digram.rb +3 -3
- data/lib/sequitur/dynamic_grammar.rb +4 -5
- data/lib/sequitur/formatter/base_formatter.rb +1 -1
- data/lib/sequitur/formatter/base_text.rb +3 -7
- data/lib/sequitur/formatter/debug.rb +0 -1
- data/lib/sequitur/grammar_visitor.rb +1 -1
- data/lib/sequitur/production.rb +200 -205
- data/lib/sequitur/production_ref.rb +9 -12
- data/lib/sequitur/sequitur_grammar.rb +135 -137
- data/lib/sequitur/symbol_sequence.rb +24 -27
- data/lib/sequitur.rb +4 -5
- data/spec/sequitur/digram_spec.rb +13 -12
- data/spec/sequitur/dynamic_grammar_spec.rb +5 -11
- data/spec/sequitur/formatter/base_text_spec.rb +70 -72
- data/spec/sequitur/formatter/debug_spec.rb +90 -92
- data/spec/sequitur/grammar_visitor_spec.rb +70 -71
- data/spec/sequitur/production_ref_spec.rb +92 -92
- data/spec/sequitur/production_spec.rb +30 -34
- data/spec/sequitur/sequitur_grammar_spec.rb +48 -49
- data/spec/sequitur/symbol_sequence_spec.rb +102 -105
- data/spec/spec_helper.rb +0 -15
- metadata +18 -60
- data/.simplecov +0 -7
- data/.travis.yml +0 -29
|
@@ -8,111 +8,108 @@ require_relative '../../lib/sequitur/production_ref'
|
|
|
8
8
|
require_relative '../../lib/sequitur/production'
|
|
9
9
|
|
|
10
10
|
module Sequitur # Re-open the module to get rid of qualified names
|
|
11
|
-
describe SymbolSequence do
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
end
|
|
114
|
-
end # context
|
|
115
|
-
end # describe
|
|
11
|
+
describe SymbolSequence do
|
|
12
|
+
let(:instance) { SymbolSequence.new }
|
|
13
|
+
|
|
14
|
+
context 'Creation and initialization:' do
|
|
15
|
+
it 'should be created without argument' do
|
|
16
|
+
expect { SymbolSequence.new }.not_to raise_error
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should be empty at creation' do
|
|
20
|
+
expect(subject).to be_empty
|
|
21
|
+
end
|
|
22
|
+
end # context
|
|
23
|
+
|
|
24
|
+
context 'Provided services:' do
|
|
25
|
+
let(:a_prod) { Production.new }
|
|
26
|
+
|
|
27
|
+
subject do
|
|
28
|
+
an_instance = SymbolSequence.new
|
|
29
|
+
%i[a b c].each { |a_sym| an_instance << a_sym }
|
|
30
|
+
an_instance
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should deep-copy clone itself' do
|
|
34
|
+
ref = ProductionRef.new(a_prod)
|
|
35
|
+
|
|
36
|
+
a = 'a'
|
|
37
|
+
c = 'c'
|
|
38
|
+
[a, ref, c].each { |ch| instance << ch }
|
|
39
|
+
clone_a = instance.clone
|
|
40
|
+
|
|
41
|
+
# Check that cloning works
|
|
42
|
+
expect(clone_a).to eq(instance)
|
|
43
|
+
|
|
44
|
+
# Reference objects are distinct but points to same production
|
|
45
|
+
expect(clone_a.symbols[1].object_id).not_to eq(instance.symbols[1])
|
|
46
|
+
|
|
47
|
+
# Modifying the clone...
|
|
48
|
+
clone_a.symbols[1] = 'diff'
|
|
49
|
+
expect(clone_a).not_to eq(instance)
|
|
50
|
+
|
|
51
|
+
# ... should leave original unchanged
|
|
52
|
+
expect(instance.symbols[1]).to eq(ref)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'should tell that it is equal to itself' do
|
|
56
|
+
# Case: Non-empty sequence
|
|
57
|
+
expect(subject).to eq(subject)
|
|
58
|
+
|
|
59
|
+
# Case: empty sequence
|
|
60
|
+
expect(instance).to eq(instance)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'should know whether it is equal to another instance' do
|
|
64
|
+
expect(instance).to eq(instance)
|
|
65
|
+
|
|
66
|
+
expect(subject).not_to eq(instance)
|
|
67
|
+
%i[a b c].each { |a_sym| instance << a_sym }
|
|
68
|
+
expect(subject).to eq(instance)
|
|
69
|
+
|
|
70
|
+
# Check that element order is relevant
|
|
71
|
+
instance.symbols.rotate!
|
|
72
|
+
expect(subject).not_to eq(instance)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'should know whether it is equal to an array' do
|
|
76
|
+
expect(subject).to eq(%i[a b c])
|
|
77
|
+
|
|
78
|
+
# Check that element order is relevant
|
|
79
|
+
expect(subject).not_to eq(%i[c b a])
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'should know that is not equal to something else' do
|
|
83
|
+
expect(subject).not_to eq(:abc)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'should know its references' do
|
|
87
|
+
ref = ProductionRef.new(a_prod)
|
|
88
|
+
2.times { subject << ref }
|
|
89
|
+
|
|
90
|
+
refs = subject.references
|
|
91
|
+
expect(refs.size).to eq(2)
|
|
92
|
+
expect(refs).to eq([ref, ref])
|
|
93
|
+
|
|
94
|
+
refs = subject.references
|
|
95
|
+
expect(refs.size).to eq(2)
|
|
96
|
+
expect(refs).to eq([ref, ref])
|
|
97
|
+
specific_refs = subject.references_of(a_prod)
|
|
98
|
+
expect(specific_refs).to eq(refs)
|
|
99
|
+
|
|
100
|
+
another = Production.new
|
|
101
|
+
another_ref = ProductionRef.new(another)
|
|
102
|
+
subject << another_ref
|
|
103
|
+
refs = subject.references
|
|
104
|
+
expect(refs.size).to eq(3)
|
|
105
|
+
expect(refs).to eq([ref, ref, another])
|
|
106
|
+
specific_refs = subject.references_of(a_prod)
|
|
107
|
+
expect(specific_refs).to eq([ref, ref])
|
|
108
|
+
specific_refs = subject.references_of(another)
|
|
109
|
+
expect(specific_refs).to eq([another])
|
|
110
|
+
end
|
|
111
|
+
end # context
|
|
112
|
+
end # describe
|
|
116
113
|
end # module
|
|
117
114
|
|
|
118
115
|
# End of file
|
data/spec/spec_helper.rb
CHANGED
|
@@ -3,21 +3,7 @@
|
|
|
3
3
|
# File: spec_helper.rb
|
|
4
4
|
# Purpose: utility file that is loaded by all our RSpec files
|
|
5
5
|
|
|
6
|
-
require 'simplecov'
|
|
7
|
-
require 'coveralls'
|
|
8
|
-
|
|
9
|
-
Coveralls.wear!
|
|
10
|
-
|
|
11
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
|
12
|
-
[
|
|
13
|
-
SimpleCov::Formatter::HTMLFormatter,
|
|
14
|
-
Coveralls::SimpleCov::Formatter
|
|
15
|
-
]
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
6
|
require 'rspec' # Use the RSpec framework
|
|
20
|
-
require 'pp' # Use pretty-print for debugging purposes
|
|
21
7
|
|
|
22
8
|
RSpec.configure do |config|
|
|
23
9
|
config.expect_with :rspec do |c|
|
|
@@ -29,5 +15,4 @@ RSpec.configure do |config|
|
|
|
29
15
|
config.full_backtrace = true
|
|
30
16
|
end
|
|
31
17
|
|
|
32
|
-
|
|
33
18
|
# End of file
|
metadata
CHANGED
|
@@ -1,115 +1,75 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sequitur
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.24
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dimitri Geshef
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-07-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: coveralls
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.7.0
|
|
20
|
-
- - "~>"
|
|
21
|
-
- !ruby/object:Gem::Version
|
|
22
|
-
version: '0.7'
|
|
23
|
-
type: :development
|
|
24
|
-
prerelease: false
|
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
-
requirements:
|
|
27
|
-
- - ">="
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
version: 0.7.0
|
|
30
|
-
- - "~>"
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '0.7'
|
|
33
13
|
- !ruby/object:Gem::Dependency
|
|
34
14
|
name: rake
|
|
35
15
|
requirement: !ruby/object:Gem::Requirement
|
|
36
16
|
requirements:
|
|
37
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
38
18
|
- !ruby/object:Gem::Version
|
|
39
19
|
version: 10.0.0
|
|
40
|
-
- - "
|
|
20
|
+
- - ">="
|
|
41
21
|
- !ruby/object:Gem::Version
|
|
42
22
|
version: 10.0.0
|
|
43
23
|
type: :development
|
|
44
24
|
prerelease: false
|
|
45
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
46
26
|
requirements:
|
|
47
|
-
- - "
|
|
27
|
+
- - "~>"
|
|
48
28
|
- !ruby/object:Gem::Version
|
|
49
29
|
version: 10.0.0
|
|
50
|
-
- - "
|
|
30
|
+
- - ">="
|
|
51
31
|
- !ruby/object:Gem::Version
|
|
52
32
|
version: 10.0.0
|
|
53
33
|
- !ruby/object:Gem::Dependency
|
|
54
34
|
name: rspec
|
|
55
35
|
requirement: !ruby/object:Gem::Requirement
|
|
56
36
|
requirements:
|
|
57
|
-
- - "
|
|
37
|
+
- - "~>"
|
|
58
38
|
- !ruby/object:Gem::Version
|
|
59
39
|
version: 3.0.0
|
|
60
|
-
- - "
|
|
40
|
+
- - ">="
|
|
61
41
|
- !ruby/object:Gem::Version
|
|
62
42
|
version: 3.0.0
|
|
63
43
|
type: :development
|
|
64
44
|
prerelease: false
|
|
65
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
46
|
requirements:
|
|
67
|
-
- - "
|
|
47
|
+
- - "~>"
|
|
68
48
|
- !ruby/object:Gem::Version
|
|
69
49
|
version: 3.0.0
|
|
70
|
-
- - "
|
|
50
|
+
- - ">="
|
|
71
51
|
- !ruby/object:Gem::Version
|
|
72
52
|
version: 3.0.0
|
|
73
53
|
- !ruby/object:Gem::Dependency
|
|
74
54
|
name: rubygems
|
|
75
55
|
requirement: !ruby/object:Gem::Requirement
|
|
76
56
|
requirements:
|
|
77
|
-
- - ">="
|
|
78
|
-
- !ruby/object:Gem::Version
|
|
79
|
-
version: 2.0.0
|
|
80
57
|
- - "~>"
|
|
81
58
|
- !ruby/object:Gem::Version
|
|
82
59
|
version: '2.0'
|
|
83
|
-
type: :development
|
|
84
|
-
prerelease: false
|
|
85
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
60
|
- - ">="
|
|
88
61
|
- !ruby/object:Gem::Version
|
|
89
62
|
version: 2.0.0
|
|
90
|
-
- - "~>"
|
|
91
|
-
- !ruby/object:Gem::Version
|
|
92
|
-
version: '2.0'
|
|
93
|
-
- !ruby/object:Gem::Dependency
|
|
94
|
-
name: simplecov
|
|
95
|
-
requirement: !ruby/object:Gem::Requirement
|
|
96
|
-
requirements:
|
|
97
|
-
- - ">="
|
|
98
|
-
- !ruby/object:Gem::Version
|
|
99
|
-
version: 0.8.0
|
|
100
|
-
- - "~>"
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: 0.8.0
|
|
103
63
|
type: :development
|
|
104
64
|
prerelease: false
|
|
105
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
66
|
requirements:
|
|
107
|
-
- - ">="
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: 0.8.0
|
|
110
67
|
- - "~>"
|
|
111
68
|
- !ruby/object:Gem::Version
|
|
112
|
-
version:
|
|
69
|
+
version: '2.0'
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: 2.0.0
|
|
113
73
|
description: |
|
|
114
74
|
Ruby implementation of the Sequitur algorithm. This algorithm automatically
|
|
115
75
|
finds repetitions and hierarchical structures in a given sequence of input
|
|
@@ -127,8 +87,6 @@ files:
|
|
|
127
87
|
- ".rspec"
|
|
128
88
|
- ".rubocop.yml"
|
|
129
89
|
- ".ruby-gemset"
|
|
130
|
-
- ".simplecov"
|
|
131
|
-
- ".travis.yml"
|
|
132
90
|
- ".yardopts"
|
|
133
91
|
- CHANGELOG.md
|
|
134
92
|
- Gemfile
|
|
@@ -179,15 +137,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
179
137
|
requirements:
|
|
180
138
|
- - ">="
|
|
181
139
|
- !ruby/object:Gem::Version
|
|
182
|
-
version:
|
|
140
|
+
version: 3.0.0
|
|
183
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
142
|
requirements:
|
|
185
143
|
- - ">="
|
|
186
144
|
- !ruby/object:Gem::Version
|
|
187
145
|
version: '0'
|
|
188
146
|
requirements: []
|
|
189
|
-
rubygems_version: 3.
|
|
190
|
-
signing_key:
|
|
147
|
+
rubygems_version: 3.3.7
|
|
148
|
+
signing_key:
|
|
191
149
|
specification_version: 4
|
|
192
150
|
summary: Ruby implementation of the Sequitur algorithm
|
|
193
151
|
test_files:
|
data/.simplecov
DELETED
data/.travis.yml
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
dist: trusty
|
|
3
|
-
|
|
4
|
-
before_install:
|
|
5
|
-
- gem update --system
|
|
6
|
-
- gem install bundler
|
|
7
|
-
|
|
8
|
-
script:
|
|
9
|
-
- bundle exec rake
|
|
10
|
-
|
|
11
|
-
rvm:
|
|
12
|
-
- 2.6.3
|
|
13
|
-
- 2.5.5
|
|
14
|
-
- 2.4.6
|
|
15
|
-
- 2.3.8
|
|
16
|
-
- ruby-head
|
|
17
|
-
- jruby-9.1.9.0
|
|
18
|
-
- jruby-head
|
|
19
|
-
|
|
20
|
-
matrix:
|
|
21
|
-
allow_failures:
|
|
22
|
-
- rvm: ruby-head
|
|
23
|
-
- rvm: jruby-head
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# whitelist
|
|
27
|
-
branches:
|
|
28
|
-
only:
|
|
29
|
-
- master
|