sequitur 0.1.23 → 0.1.25
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 -437
- data/CHANGELOG.md +9 -0
- data/Gemfile +0 -2
- data/LICENSE.txt +1 -1
- data/README.md +2 -3
- data/Rakefile +0 -2
- data/appveyor.yml +10 -10
- data/examples/inductive_english.rb +35 -0
- data/examples/integer_sample.rb +0 -1
- data/examples/porridge.rb +9 -9
- data/examples/word_sample.rb +4 -5
- data/lib/sequitur/constants.rb +7 -4
- data/lib/sequitur/digram.rb +11 -11
- data/lib/sequitur/dynamic_grammar.rb +12 -12
- data/lib/sequitur/formatter/base_formatter.rb +2 -2
- data/lib/sequitur/formatter/base_text.rb +8 -9
- data/lib/sequitur/formatter/debug.rb +10 -4
- data/lib/sequitur/grammar_visitor.rb +7 -7
- data/lib/sequitur/production.rb +203 -205
- data/lib/sequitur/production_ref.rb +18 -20
- data/lib/sequitur/sequitur_grammar.rb +135 -137
- data/lib/sequitur/symbol_sequence.rb +29 -32
- data/lib/sequitur.rb +6 -6
- data/sig/lib/sequitur/constants.rbs +10 -0
- data/sig/lib/sequitur/digram.rbs +37 -0
- data/sig/lib/sequitur/dynamic_grammar.rbs +58 -0
- data/sig/lib/sequitur/formatter/base_formatter.rbs +20 -0
- data/sig/lib/sequitur/formatter/base_text.rbs +62 -0
- data/sig/lib/sequitur/formatter/debug.rbs +89 -0
- data/sig/lib/sequitur/production.rbs +120 -0
- data/sig/lib/sequitur/production_ref.rbs +73 -0
- data/sig/lib/sequitur/sequitur_grammar.rbs +55 -0
- data/sig/lib/sequitur/symbol_sequence.rbs +83 -0
- data/sig/lib/sequitur.rbs +9 -0
- 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 +47 -46
- data/spec/sequitur/symbol_sequence_spec.rb +102 -105
- data/spec/spec_helper.rb +0 -1
- metadata +28 -17
- data/.travis.yml +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f70c8a02c1bf095a4ace46d340afe5479ca74fca119c99018f635d629e10af79
|
4
|
+
data.tar.gz: d61df7bc573f20b46edddafb207a5e1c8b98f5a940337b3d3ddcda378aed5f98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0be273d0ae70f7cade11ff86af7ae8f52ca4c697c471a8925ee3e75d230d4c0df261fba908e875413903a6ad6e0cba067ca5778e0d91d4fc35e74f00a00c536
|
7
|
+
data.tar.gz: a352a03ebefe1683e74a59e5d5766eafb44780c65af7f65fe2b6441d15d00193cd1d913976bd7b8cc2e4414a888ec5bd5d6bb0b184be8ecee196398629af1458
|
data/.rubocop.yml
CHANGED
@@ -1,456 +1,30 @@
|
|
1
1
|
AllCops:
|
2
2
|
Exclude:
|
3
|
-
- 'exp/**/*'
|
4
3
|
- 'lab/**/*'
|
5
|
-
|
6
|
-
Gemspec/DateAssignment:
|
7
|
-
Enabled: true
|
8
|
-
|
9
|
-
Layout/ArgumentAlignment:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
Layout/ArrayAlignment:
|
13
|
-
Enabled: true
|
14
|
-
EnforcedStyle: with_fixed_indentation
|
15
|
-
|
16
|
-
Layout/CaseIndentation:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Layout/ClosingHeredocIndentation:
|
20
|
-
Enabled: false
|
21
|
-
|
22
|
-
Layout/CommentIndentation:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Layout/ElseAlignment:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
Layout/EmptyLines:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
Layout/EndAlignment:
|
32
|
-
Enabled: false
|
33
|
-
|
4
|
+
|
34
5
|
Layout/EndOfLine:
|
35
|
-
Enabled:
|
36
|
-
EnforcedStyle: lf
|
37
|
-
|
38
|
-
Layout/FirstArgumentIndentation:
|
39
|
-
Enabled: false
|
40
|
-
|
41
|
-
Layout/HashAlignment:
|
42
|
-
Enabled: false
|
43
|
-
|
44
|
-
Layout/IndentationWidth:
|
45
|
-
Enabled: false
|
46
|
-
|
47
|
-
Layout/IndentationConsistency:
|
48
|
-
Enabled: true
|
49
|
-
|
50
|
-
Layout/HeredocIndentation:
|
51
|
-
Enabled: false
|
52
|
-
|
53
|
-
Layout/LineEndStringConcatenationIndentation:
|
54
|
-
Enabled: true
|
55
|
-
|
56
|
-
Layout/MultilineHashBraceLayout:
|
57
|
-
Enabled: true
|
58
|
-
|
59
|
-
Layout/MultilineMethodCallBraceLayout:
|
60
|
-
Enabled: true
|
61
|
-
EnforcedStyle: same_line
|
62
|
-
|
63
|
-
Layout/SpaceAroundOperators:
|
64
|
-
Enabled: true
|
65
|
-
|
66
|
-
Layout/SpaceBeforeBrackets:
|
67
|
-
Enabled: true
|
68
|
-
|
69
|
-
Layout/SpaceInsideParens:
|
70
|
-
Enabled: true
|
71
|
-
|
72
|
-
Layout/IndentationStyle:
|
73
|
-
Enabled: true
|
74
|
-
|
75
|
-
Layout/SpaceAroundMethodCallOperator:
|
76
|
-
Enabled: true
|
77
|
-
|
78
|
-
Layout/TrailingEmptyLines:
|
79
|
-
Enabled: true
|
80
|
-
|
81
|
-
Layout/TrailingWhitespace:
|
82
|
-
Enabled: true
|
83
|
-
|
84
|
-
Lint/AmbiguousAssignment:
|
85
|
-
Enabled: true
|
86
|
-
|
87
|
-
Lint/AmbiguousRange:
|
88
|
-
Enabled: true
|
89
|
-
|
90
|
-
Lint/DeprecatedConstants:
|
91
|
-
Enabled: true
|
92
|
-
|
93
|
-
Lint/DuplicateBranch:
|
94
|
-
Enabled: true
|
95
|
-
|
96
|
-
Lint/DuplicateRegexpCharacterClassElement:
|
97
|
-
Enabled: true
|
98
|
-
|
99
|
-
Lint/EmptyBlock:
|
100
|
-
Enabled: true
|
101
|
-
|
102
|
-
Lint/EmptyClass:
|
103
|
-
Enabled: false
|
104
|
-
|
105
|
-
Lint/EmptyInPattern:
|
106
|
-
Enabled: true
|
107
|
-
|
108
|
-
Lint/LambdaWithoutLiteralBlock:
|
109
|
-
Enabled: true
|
110
|
-
|
111
|
-
Lint/Loop:
|
112
|
-
Enabled: true
|
113
|
-
|
114
|
-
Lint/NoReturnInBeginEndBlocks:
|
115
|
-
Enabled: true
|
116
|
-
|
117
|
-
Lint/NumberedParameterAssignment:
|
118
|
-
Enabled: true
|
119
|
-
|
120
|
-
Lint/OrAssignmentToConstant:
|
121
|
-
Enabled: true
|
122
|
-
|
123
|
-
Lint/RaiseException:
|
124
|
-
Enabled: true
|
125
|
-
|
126
|
-
Lint/RedundantDirGlobSort:
|
127
|
-
Enabled: true
|
128
|
-
|
129
|
-
Lint/RescueException:
|
130
|
-
Enabled: true
|
131
|
-
|
132
|
-
Lint/StructNewOverride:
|
133
|
-
Enabled: true
|
134
|
-
|
135
|
-
Lint/SymbolConversion:
|
136
|
-
Enabled: true
|
137
|
-
|
138
|
-
Lint/ToEnumArguments:
|
139
|
-
Enabled: true
|
140
|
-
|
141
|
-
Lint/TripleQuotes:
|
142
|
-
Enabled: true
|
143
|
-
|
144
|
-
Lint/UnexpectedBlockArity:
|
145
|
-
Enabled: true
|
146
|
-
|
147
|
-
Lint/UnmodifiedReduceAccumulator:
|
148
|
-
Enabled: true
|
149
|
-
|
150
|
-
Lint/UnusedMethodArgument:
|
151
|
-
Enabled: true
|
152
|
-
|
153
|
-
Lint/UselessAccessModifier:
|
154
|
-
Enabled: true
|
155
|
-
|
156
|
-
Lint/Void:
|
157
|
-
Enabled: false
|
158
|
-
|
159
|
-
Lint/UselessAssignment:
|
160
|
-
Enabled: true
|
6
|
+
Enabled: false # Make source portable!
|
161
7
|
|
162
8
|
Metrics/AbcSize:
|
163
|
-
|
164
|
-
|
165
|
-
Metrics/BlockLength:
|
166
|
-
Enabled: true
|
167
|
-
Max: 350
|
168
|
-
|
169
|
-
Metrics/BlockNesting:
|
170
|
-
Enabled: true
|
171
|
-
Max: 5
|
9
|
+
Max: 22
|
172
10
|
|
173
11
|
Metrics/ClassLength:
|
174
|
-
|
175
|
-
|
176
|
-
|
12
|
+
Max: 150
|
13
|
+
|
177
14
|
Metrics/CyclomaticComplexity:
|
178
|
-
|
179
|
-
|
180
|
-
Layout/LineLength:
|
181
|
-
Enabled: false
|
182
|
-
Max: 90
|
15
|
+
Max: 10
|
183
16
|
|
184
17
|
Metrics/MethodLength:
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
Metrics/ModuleLength:
|
189
|
-
Enabled: true
|
190
|
-
Max: 500
|
191
|
-
|
18
|
+
Max: 50
|
19
|
+
|
192
20
|
Metrics/PerceivedComplexity:
|
193
|
-
|
194
|
-
|
195
|
-
Naming/ConstantName:
|
196
|
-
Enabled: false
|
197
|
-
|
198
|
-
Naming/ClassAndModuleCamelCase:
|
199
|
-
Enabled: false
|
200
|
-
|
201
|
-
Naming/BlockParameterName:
|
202
|
-
Enabled: true
|
203
|
-
|
204
|
-
Naming/InclusiveLanguage:
|
205
|
-
Enabled: true
|
21
|
+
Max: 10
|
206
22
|
|
207
23
|
Naming/MethodParameterName:
|
208
24
|
Enabled: false
|
209
|
-
|
210
|
-
Naming/MethodName:
|
211
|
-
Enabled: false
|
212
|
-
|
25
|
+
|
213
26
|
Naming/VariableName:
|
214
27
|
Enabled: false
|
215
28
|
|
216
|
-
Style/AccessorGrouping:
|
217
|
-
Enabled: false
|
218
|
-
|
219
|
-
Style/Alias:
|
220
|
-
Enabled: true
|
221
|
-
|
222
|
-
Style/ArgumentsForwarding:
|
223
|
-
Enabled: true
|
224
|
-
|
225
|
-
Style/AsciiComments:
|
226
|
-
Enabled: false
|
227
|
-
|
228
|
-
Style/BarePercentLiterals:
|
229
|
-
Enabled: false
|
230
|
-
|
231
|
-
Style/BlockComments:
|
232
|
-
Enabled: false
|
233
|
-
|
234
|
-
Style/CharacterLiteral:
|
235
|
-
Enabled: false
|
236
|
-
|
237
|
-
Style/ClassCheck:
|
238
|
-
Enabled: false
|
239
|
-
|
240
|
-
Style/ClassVars:
|
241
|
-
Enabled: false
|
242
|
-
|
243
|
-
Style/CollectionCompact:
|
244
|
-
Enabled: true
|
245
|
-
|
246
|
-
Style/ColonMethodCall:
|
247
|
-
Enabled: false
|
248
|
-
|
249
|
-
Style/CommentAnnotation:
|
250
|
-
Enabled: false
|
251
|
-
|
252
29
|
Style/CommentedKeyword:
|
253
|
-
Enabled: false
|
254
|
-
|
255
|
-
Style/ConditionalAssignment:
|
256
|
-
Enabled: false
|
257
|
-
|
258
|
-
Style/DefWithParentheses:
|
259
|
-
Enabled: true
|
260
|
-
|
261
|
-
Style/Documentation:
|
262
|
-
Enabled: false
|
263
|
-
|
264
|
-
Style/DocumentDynamicEvalDefinition:
|
265
|
-
Enabled: false
|
266
|
-
|
267
|
-
Style/EmptyElse:
|
268
|
-
Enabled: true
|
269
|
-
EnforcedStyle: empty
|
270
|
-
|
271
|
-
Style/ExpandPathArguments:
|
272
|
-
Enabled: false
|
273
|
-
|
274
|
-
Style/ExponentialNotation:
|
275
|
-
Enabled: true
|
276
|
-
|
277
|
-
Style/GuardClause:
|
278
|
-
Enabled: false
|
279
|
-
|
280
|
-
Style/HashEachMethods:
|
281
|
-
Enabled: true
|
282
|
-
|
283
|
-
Style/HashExcept:
|
284
|
-
Enabled: true
|
285
|
-
|
286
|
-
Style/HashTransformKeys:
|
287
|
-
Enabled: true
|
288
|
-
|
289
|
-
Style/HashTransformValues:
|
290
|
-
Enabled: true
|
291
|
-
|
292
|
-
Style/IfUnlessModifier:
|
293
|
-
Enabled: false
|
294
|
-
|
295
|
-
Style/InPatternThen:
|
296
|
-
Enabled: true
|
297
|
-
|
298
|
-
Style/InverseMethods:
|
299
|
-
Enabled: false
|
300
|
-
|
301
|
-
Style/MissingRespondToMissing:
|
302
|
-
Enabled: false
|
303
|
-
|
304
|
-
Style/MultilineInPatternThen:
|
305
|
-
Enabled: true
|
306
|
-
|
307
|
-
Style/NegatedIfElseCondition:
|
308
|
-
Enabled: true
|
309
|
-
|
310
|
-
Style/Next:
|
311
|
-
Enabled: false
|
312
|
-
|
313
|
-
Style/NilLambda:
|
314
|
-
Enabled: true
|
315
|
-
|
316
|
-
Style/NumericLiterals:
|
317
|
-
Enabled: false
|
318
|
-
|
319
|
-
Style/QuotedSymbols:
|
320
|
-
Enabled: true
|
321
|
-
|
322
|
-
Style/RaiseArgs:
|
323
|
-
Enabled: true
|
324
|
-
|
325
|
-
Style/RedundantArgument:
|
326
|
-
Enabled: true
|
327
|
-
|
328
|
-
Style/RedundantReturn:
|
329
|
-
Enabled: false
|
330
|
-
|
331
|
-
Style/RedundantSelf:
|
332
|
-
Enabled: true
|
333
|
-
|
334
|
-
Style/RedundantSelfAssignmentBranch:
|
335
|
-
Enabled: true
|
336
|
-
|
337
|
-
Style/RegexpLiteral:
|
338
|
-
Enabled: false
|
339
|
-
|
340
|
-
Style/PercentLiteralDelimiters:
|
341
|
-
Enabled: false
|
342
|
-
|
343
|
-
Style/StderrPuts:
|
344
|
-
Enabled: false
|
345
|
-
|
346
|
-
Style/StringLiterals:
|
347
|
-
Enabled: true
|
348
|
-
|
349
|
-
Style/SwapValues:
|
350
|
-
Enabled: true
|
351
|
-
|
352
|
-
Style/TernaryParentheses:
|
353
|
-
Enabled: false
|
354
|
-
|
355
|
-
Style/UnlessElse:
|
356
|
-
Enabled: false
|
357
|
-
|
358
|
-
# Rubocop complains when it doesn't find an explicit setting for the following cops:
|
359
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
360
|
-
Enabled: true
|
361
|
-
|
362
|
-
Lint/BinaryOperatorWithIdenticalOperands:
|
363
|
-
Enabled: true
|
364
|
-
|
365
|
-
Lint/DeprecatedOpenSSLConstant:
|
366
|
-
Enabled: true
|
367
|
-
|
368
|
-
Lint/DuplicateElsifCondition:
|
369
|
-
Enabled: true
|
370
|
-
|
371
|
-
Lint/DuplicateRescueException:
|
372
|
-
Enabled: true
|
373
|
-
|
374
|
-
Lint/EmptyConditionalBody:
|
375
|
-
Enabled: true
|
376
|
-
|
377
|
-
Lint/FloatComparison:
|
378
|
-
Enabled: true
|
379
|
-
|
380
|
-
Lint/MissingSuper:
|
381
|
-
Enabled: true
|
382
|
-
|
383
|
-
Lint/MixedRegexpCaptureTypes:
|
384
|
-
Enabled: true
|
385
|
-
|
386
|
-
Lint/OutOfRangeRegexpRef:
|
387
|
-
Enabled: true
|
388
|
-
|
389
|
-
Lint/SelfAssignment:
|
390
|
-
Enabled: true
|
391
|
-
|
392
|
-
Lint/TopLevelReturnWithArgument:
|
393
|
-
Enabled: true
|
394
|
-
|
395
|
-
Lint/UnreachableLoop:
|
396
|
-
Enabled: true
|
397
|
-
|
398
|
-
Style/ArrayCoercion:
|
399
|
-
Enabled: true
|
400
|
-
|
401
|
-
Style/BisectedAttrAccessor:
|
402
|
-
Enabled: true
|
403
|
-
|
404
|
-
Style/CaseLikeIf:
|
405
|
-
Enabled: true
|
406
|
-
|
407
|
-
Style/EndlessMethod:
|
408
|
-
Enabled: true
|
409
|
-
|
410
|
-
Style/ExplicitBlockArgument:
|
411
|
-
Enabled: true
|
412
|
-
|
413
|
-
Style/GlobalStdStream:
|
414
|
-
Enabled: true
|
415
|
-
|
416
|
-
Style/HashAsLastArrayItem:
|
417
|
-
Enabled: true
|
418
|
-
|
419
|
-
Style/HashConversion:
|
420
|
-
Enabled: true
|
421
|
-
|
422
|
-
Style/HashLikeCase:
|
423
|
-
Enabled: true
|
424
|
-
|
425
|
-
Style/IfWithBooleanLiteralBranches:
|
426
|
-
Enabled: true
|
427
|
-
|
428
|
-
Style/OptionalBooleanParameter:
|
429
|
-
Enabled: true
|
430
|
-
|
431
|
-
Style/RedundantAssignment:
|
432
|
-
Enabled: true
|
433
|
-
|
434
|
-
Style/RedundantFetchBlock:
|
435
|
-
Enabled: true
|
436
|
-
|
437
|
-
Style/RedundantFileExtensionInRequire:
|
438
|
-
Enabled: true
|
439
|
-
|
440
|
-
Style/RedundantRegexpCharacterClass:
|
441
|
-
Enabled: true
|
442
|
-
|
443
|
-
Style/RedundantRegexpEscape:
|
444
|
-
Enabled: true
|
445
|
-
|
446
|
-
Style/SingleArgumentDig:
|
447
|
-
Enabled: true
|
448
|
-
|
449
|
-
Style/SlicingWithRange:
|
450
|
-
Enabled: true
|
451
|
-
|
452
|
-
Style/StringChars:
|
453
|
-
Enabled: true
|
454
|
-
|
455
|
-
Style/StringConcatenation:
|
456
|
-
Enabled: true
|
30
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [0.1.25] - 2023-07-10
|
2
|
+
- First version using RBS (Ruby Type System): new folder `sig` with `*.rbs` files
|
3
|
+
- Yard documentation updated to align with RBS
|
4
|
+
- File `appveyor.yml` updated to cover Rubies 2.6, .., 3.1
|
5
|
+
- File `Gemfile`: removed dependencies to `simplecov` and `coverall`
|
6
|
+
|
7
|
+
## [0.1.24] - 2023-07-01
|
8
|
+
- Code restyling to please rubocop 1.53.1
|
9
|
+
|
1
10
|
## [0.1.23] - 2021-09-04
|
2
11
|
- Remove dependencies towards `coverall`, `simplecov`
|
3
12
|
- Code restyling to please rubocop 1.19.1
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -3,9 +3,8 @@ Sequitur
|
|
3
3
|
_Ruby gem implementing the Sequitur algorithm_
|
4
4
|
[Homepage](https://github.com/famished-tiger/Sequitur)
|
5
5
|
|
6
|
-
|
6
|
+
|
7
7
|
[](https://ci.appveyor.com/project/famished-tiger/sequitur)
|
8
|
-
[](https://coveralls.io/r/famished-tiger/Sequitur)
|
9
8
|
[](http://badge.fury.io/rb/sequitur)
|
10
9
|
[](http://inch-ci.org/github/famished-tiger/Sequitur)
|
11
10
|
[](https://codeclimate.com/github/famished-tiger/Sequitur)
|
@@ -247,4 +246,4 @@ More examples are available in the examples folder.
|
|
247
246
|
|
248
247
|
Copyright
|
249
248
|
---------
|
250
|
-
Copyright (c) 2014-
|
249
|
+
Copyright (c) 2014-2013, Dimitri Geshef. Sequitur is released under the MIT License see [LICENSE.txt](https://github.com/famished-tiger/Sequitur/blob/master/LICENSE.txt) for details.
|
data/Rakefile
CHANGED
data/appveyor.yml
CHANGED
@@ -2,19 +2,19 @@ version: '{build}'
|
|
2
2
|
max_jobs: 5
|
3
3
|
environment:
|
4
4
|
matrix:
|
5
|
-
- Ruby_version:
|
6
|
-
- Ruby_version:
|
7
|
-
- Ruby_version:
|
8
|
-
- Ruby_version:
|
9
|
-
- Ruby_version:
|
10
|
-
- Ruby_version:
|
11
|
-
- Ruby_version: 24
|
12
|
-
- Ruby_version: 23
|
5
|
+
- Ruby_version: 31-x64
|
6
|
+
- Ruby_version: 30-x64
|
7
|
+
- Ruby_version: 27-x64
|
8
|
+
- Ruby_version: 31
|
9
|
+
- Ruby_version: 30
|
10
|
+
- Ruby_version: 27
|
13
11
|
|
12
|
+
# - gem update --system --source http://rubygems.org/
|
14
13
|
install:
|
15
14
|
- set PATH=C:\Ruby%Ruby_version%\bin;%PATH%
|
16
|
-
-
|
17
|
-
- gem install
|
15
|
+
- ruby --version
|
16
|
+
- gem install rubygems-update
|
17
|
+
- gem install bundler
|
18
18
|
- bundle install --retry=3 --clean --force
|
19
19
|
|
20
20
|
build: off
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Demo of sequitur gem: from a set of sentences, generate a context-free grammar
|
4
|
+
|
5
|
+
require 'engtagger'
|
6
|
+
require 'sequitur'
|
7
|
+
|
8
|
+
# Simple sentences taken from the first lesson of "Learn These Words First".
|
9
|
+
# ( https://learnthesewordsfirst.com/ )
|
10
|
+
sentences = <<~END_TEXT
|
11
|
+
Tony sees Lisa.
|
12
|
+
Tony sees something.
|
13
|
+
Lisa sees something.
|
14
|
+
Tony sees this thing.
|
15
|
+
Lisa sees the other thing.
|
16
|
+
END_TEXT
|
17
|
+
|
18
|
+
tagger = EngTagger.new
|
19
|
+
pairs = tagger.tag_pairs(sentences)
|
20
|
+
tag_sequence = pairs.map(&:last)
|
21
|
+
|
22
|
+
# Generate the grammar from the tag sequence
|
23
|
+
grammar = Sequitur.build_from(tag_sequence)
|
24
|
+
|
25
|
+
# Use a formatter to display the grammar rules on the console output
|
26
|
+
formatter = Sequitur::Formatter::BaseText.new($stdout)
|
27
|
+
|
28
|
+
# Now render the rules
|
29
|
+
formatter.render(grammar.visitor)
|
30
|
+
# Rendered output is:
|
31
|
+
# start : P1 nnp P2 P2 P4 nn P4 jj nn pp.
|
32
|
+
# P1 : nnp vbz.
|
33
|
+
# P2 : P3 nn.
|
34
|
+
# P3 : pp P1.
|
35
|
+
# P4 : P3 det.
|
data/examples/integer_sample.rb
CHANGED
@@ -10,7 +10,6 @@ input_sequence = [1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5]
|
|
10
10
|
# Generate the grammar from the sequence
|
11
11
|
grammar = Sequitur.build_from(input_sequence)
|
12
12
|
|
13
|
-
|
14
13
|
# Use a formatter to display the grammar rules on the console output
|
15
14
|
formatter = Sequitur::Formatter::BaseText.new($stdout)
|
16
15
|
|
data/examples/porridge.rb
CHANGED
@@ -3,16 +3,16 @@
|
|
3
3
|
require 'sequitur' # Load the Sequitur library
|
4
4
|
|
5
5
|
# Purpose: demo to show that sequitur gem works on example from sequitur.info website
|
6
|
-
input_sequence =
|
7
|
-
pease porridge hot,
|
8
|
-
pease porridge cold,
|
9
|
-
pease porridge in the pot,
|
10
|
-
nine days old.
|
6
|
+
input_sequence = <<~SNIPPET
|
7
|
+
pease porridge hot,
|
8
|
+
pease porridge cold,
|
9
|
+
pease porridge in the pot,
|
10
|
+
nine days old.
|
11
11
|
|
12
|
-
some like it hot,
|
13
|
-
some like it cold,
|
14
|
-
some like it in the pot,
|
15
|
-
nine days old.
|
12
|
+
some like it hot,
|
13
|
+
some like it cold,
|
14
|
+
some like it in the pot,
|
15
|
+
nine days old.
|
16
16
|
SNIPPET
|
17
17
|
|
18
18
|
grammar = Sequitur.build_from(input_sequence)
|
data/examples/word_sample.rb
CHANGED
@@ -7,10 +7,10 @@ require 'sequitur' # Load the Sequitur library
|
|
7
7
|
#
|
8
8
|
|
9
9
|
# Raw input is one String containing repeated sentences...
|
10
|
-
raw_input =
|
11
|
-
Error: unknown character '?' at position 6
|
12
|
-
Error: illegal character '%' at position 20
|
13
|
-
Error: unknown character '/' at position 9
|
10
|
+
raw_input = <<~SNIPPET
|
11
|
+
Error: unknown character '?' at position 6
|
12
|
+
Error: illegal character '%' at position 20
|
13
|
+
Error: unknown character '/' at position 9
|
14
14
|
SNIPPET
|
15
15
|
|
16
16
|
# Convert into a sequence of words
|
@@ -18,7 +18,6 @@ input_sequence = raw_input.scan(/\w+/)
|
|
18
18
|
# Generate the grammar from the sequence
|
19
19
|
grammar = Sequitur.build_from(input_sequence)
|
20
20
|
|
21
|
-
|
22
21
|
# Use a formatter to display the grammar rules on the console output
|
23
22
|
formatter = Sequitur::Formatter::BaseText.new($stdout)
|
24
23
|
|
data/lib/sequitur/constants.rb
CHANGED
@@ -4,10 +4,12 @@
|
|
4
4
|
# Purpose: definition of Sequitur constants.
|
5
5
|
|
6
6
|
module Sequitur # Module used as a namespace
|
7
|
-
#
|
8
|
-
Version = '0.1.23'
|
7
|
+
# rubocop:disable Naming/ConstantName
|
9
8
|
|
10
|
-
#
|
9
|
+
# @return [String] The version number of the gem.
|
10
|
+
Version = '0.1.25'
|
11
|
+
|
12
|
+
# @return [String] Brief description of the gem.
|
11
13
|
Description = 'Ruby implementation of the Sequitur algorithm'
|
12
14
|
|
13
15
|
# Constant Sequitur::RootDir contains the absolute path of Sequitur's
|
@@ -16,13 +18,14 @@ module Sequitur # Module used as a namespace
|
|
16
18
|
# The initialisation of constant RootDir is guarded in order
|
17
19
|
# to avoid multiple initialisation (not allowed for constants)
|
18
20
|
|
19
|
-
# The start folder of Sequitur.
|
21
|
+
# @return [String] The start folder of Sequitur.
|
20
22
|
RootDir = begin
|
21
23
|
require 'pathname' # Load Pathname class from standard library
|
22
24
|
startdir = Pathname(__FILE__).dirname.parent.parent.expand_path
|
23
25
|
"#{startdir}/" # Append trailing slash character to it
|
24
26
|
end
|
25
27
|
end
|
28
|
+
# rubocop:enable Naming/ConstantName
|
26
29
|
end # module
|
27
30
|
|
28
31
|
# End of file
|