sequitur 0.1.23 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -437
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +0 -2
  5. data/LICENSE.txt +1 -1
  6. data/README.md +2 -3
  7. data/Rakefile +0 -2
  8. data/appveyor.yml +10 -10
  9. data/examples/inductive_english.rb +35 -0
  10. data/examples/integer_sample.rb +0 -1
  11. data/examples/porridge.rb +9 -9
  12. data/examples/word_sample.rb +4 -5
  13. data/lib/sequitur/constants.rb +7 -4
  14. data/lib/sequitur/digram.rb +11 -11
  15. data/lib/sequitur/dynamic_grammar.rb +12 -12
  16. data/lib/sequitur/formatter/base_formatter.rb +2 -2
  17. data/lib/sequitur/formatter/base_text.rb +8 -9
  18. data/lib/sequitur/formatter/debug.rb +10 -4
  19. data/lib/sequitur/grammar_visitor.rb +7 -7
  20. data/lib/sequitur/production.rb +203 -205
  21. data/lib/sequitur/production_ref.rb +18 -20
  22. data/lib/sequitur/sequitur_grammar.rb +135 -137
  23. data/lib/sequitur/symbol_sequence.rb +29 -32
  24. data/lib/sequitur.rb +6 -6
  25. data/sig/lib/sequitur/constants.rbs +10 -0
  26. data/sig/lib/sequitur/digram.rbs +37 -0
  27. data/sig/lib/sequitur/dynamic_grammar.rbs +58 -0
  28. data/sig/lib/sequitur/formatter/base_formatter.rbs +20 -0
  29. data/sig/lib/sequitur/formatter/base_text.rbs +62 -0
  30. data/sig/lib/sequitur/formatter/debug.rbs +89 -0
  31. data/sig/lib/sequitur/production.rbs +120 -0
  32. data/sig/lib/sequitur/production_ref.rbs +73 -0
  33. data/sig/lib/sequitur/sequitur_grammar.rbs +55 -0
  34. data/sig/lib/sequitur/symbol_sequence.rbs +83 -0
  35. data/sig/lib/sequitur.rbs +9 -0
  36. data/spec/sequitur/digram_spec.rb +13 -12
  37. data/spec/sequitur/dynamic_grammar_spec.rb +5 -11
  38. data/spec/sequitur/formatter/base_text_spec.rb +70 -72
  39. data/spec/sequitur/formatter/debug_spec.rb +90 -92
  40. data/spec/sequitur/grammar_visitor_spec.rb +70 -71
  41. data/spec/sequitur/production_ref_spec.rb +92 -92
  42. data/spec/sequitur/production_spec.rb +30 -34
  43. data/spec/sequitur/sequitur_grammar_spec.rb +47 -46
  44. data/spec/sequitur/symbol_sequence_spec.rb +102 -105
  45. data/spec/spec_helper.rb +0 -1
  46. metadata +28 -17
  47. 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
- 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
-
56
- it 'should tell that it is equal to itself' do
57
- # Case: Non-empty sequence
58
- expect(subject).to eq(subject)
59
-
60
- # Case: empty sequence
61
- expect(instance).to eq(instance)
62
- end
63
-
64
- it 'should know whether it is equal to another instance' do
65
- expect(instance).to eq(instance)
66
-
67
- expect(subject).not_to eq(instance)
68
- %i[a b c].each { |a_sym| instance << a_sym }
69
- expect(subject).to eq(instance)
70
-
71
- # Check that element order is relevant
72
- instance.symbols.rotate!
73
- expect(subject).not_to eq(instance)
74
- end
75
-
76
- it 'should know whether it is equal to an array' do
77
- expect(subject).to eq(%i[a b c])
78
-
79
- # Check that element order is relevant
80
- expect(subject).not_to eq(%i[c b a])
81
- end
82
-
83
- it 'should know that is not equal to something else' do
84
- expect(subject).not_to eq(:abc)
85
- end
86
-
87
-
88
- it 'should know its references' do
89
- ref = ProductionRef.new(a_prod)
90
- 2.times { subject << ref }
91
-
92
- refs = subject.references
93
- expect(refs.size).to eq(2)
94
- expect(refs).to eq([ref, ref])
95
-
96
- refs = subject.references
97
- expect(refs.size).to eq(2)
98
- expect(refs).to eq([ref, ref])
99
- specific_refs = subject.references_of(a_prod)
100
- expect(specific_refs).to eq(refs)
101
-
102
-
103
- another = Production.new
104
- another_ref = ProductionRef.new(another)
105
- subject << another_ref
106
- refs = subject.references
107
- expect(refs.size).to eq(3)
108
- expect(refs).to eq([ref, ref, another])
109
- specific_refs = subject.references_of(a_prod)
110
- expect(specific_refs).to eq([ref, ref])
111
- specific_refs = subject.references_of(another)
112
- expect(specific_refs).to eq([another])
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
@@ -4,7 +4,6 @@
4
4
  # Purpose: utility file that is loaded by all our RSpec files
5
5
 
6
6
  require 'rspec' # Use the RSpec framework
7
- require 'pp' # Use pretty-print for debugging purposes
8
7
 
9
8
  RSpec.configure do |config|
10
9
  config.expect_with :rspec do |c|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequitur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.23
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-04 00:00:00.000000000 Z
11
+ date: 2023-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,60 +16,60 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 10.0.0
19
+ version: 13.0.0
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 10.0.0
22
+ version: 13.0.0
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 10.0.0
29
+ version: 13.0.0
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 10.0.0
32
+ version: 13.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 3.0.0
39
+ version: 3.10.0
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 3.0.0
42
+ version: 3.10.0
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 3.0.0
49
+ version: 3.10.0
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 3.0.0
52
+ version: 3.10.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rubygems
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '2.0'
59
+ version: '3.2'
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 2.0.0
62
+ version: 3.2.0
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '2.0'
69
+ version: '3.2'
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 2.0.0
72
+ version: 3.2.0
73
73
  description: |
74
74
  Ruby implementation of the Sequitur algorithm. This algorithm automatically
75
75
  finds repetitions and hierarchical structures in a given sequence of input
@@ -87,7 +87,6 @@ files:
87
87
  - ".rspec"
88
88
  - ".rubocop.yml"
89
89
  - ".ruby-gemset"
90
- - ".travis.yml"
91
90
  - ".yardopts"
92
91
  - CHANGELOG.md
93
92
  - Gemfile
@@ -95,6 +94,7 @@ files:
95
94
  - README.md
96
95
  - Rakefile
97
96
  - appveyor.yml
97
+ - examples/inductive_english.rb
98
98
  - examples/integer_sample.rb
99
99
  - examples/porridge.rb
100
100
  - examples/simple_case.rb
@@ -112,6 +112,17 @@ files:
112
112
  - lib/sequitur/production_ref.rb
113
113
  - lib/sequitur/sequitur_grammar.rb
114
114
  - lib/sequitur/symbol_sequence.rb
115
+ - sig/lib/sequitur.rbs
116
+ - sig/lib/sequitur/constants.rbs
117
+ - sig/lib/sequitur/digram.rbs
118
+ - sig/lib/sequitur/dynamic_grammar.rbs
119
+ - sig/lib/sequitur/formatter/base_formatter.rbs
120
+ - sig/lib/sequitur/formatter/base_text.rbs
121
+ - sig/lib/sequitur/formatter/debug.rbs
122
+ - sig/lib/sequitur/production.rbs
123
+ - sig/lib/sequitur/production_ref.rbs
124
+ - sig/lib/sequitur/sequitur_grammar.rbs
125
+ - sig/lib/sequitur/symbol_sequence.rbs
115
126
  - spec/sequitur/digram_spec.rb
116
127
  - spec/sequitur/dynamic_grammar_spec.rb
117
128
  - spec/sequitur/formatter/base_text_spec.rb
@@ -138,14 +149,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
149
  requirements:
139
150
  - - ">="
140
151
  - !ruby/object:Gem::Version
141
- version: 2.5.0
152
+ version: 3.0.0
142
153
  required_rubygems_version: !ruby/object:Gem::Requirement
143
154
  requirements:
144
155
  - - ">="
145
156
  - !ruby/object:Gem::Version
146
157
  version: '0'
147
158
  requirements: []
148
- rubygems_version: 3.1.4
159
+ rubygems_version: 3.3.7
149
160
  signing_key:
150
161
  specification_version: 4
151
162
  summary: Ruby implementation of the Sequitur algorithm
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