biodiversity 3.5.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +9 -6
- data/.ruby-version +1 -1
- data/.travis.yml +1 -6
- data/CHANGELOG +3 -0
- data/Gemfile +2 -0
- data/README.md +37 -178
- data/Rakefile +15 -48
- data/biodiversity.gemspec +18 -21
- data/clib/linux/libgnparser.h +93 -0
- data/clib/linux/libgnparser.so +0 -0
- data/clib/mac/libgnparser.h +93 -0
- data/clib/mac/libgnparser.so +0 -0
- data/lib/biodiversity.rb +4 -9
- data/lib/biodiversity/parser.rb +65 -281
- data/lib/biodiversity/version.rb +8 -1
- data/spec/lib/biodiversity_spec.rb +9 -0
- data/spec/lib/parser_spec.rb +38 -0
- data/spec/spec_helper.rb +4 -81
- metadata +27 -102
- data/.byebug_history +0 -18
- data/.document +0 -5
- data/examples/socket_client.rb +0 -25
- data/lib/biodiversity/guid.rb +0 -1
- data/lib/biodiversity/guid/lsid.rb +0 -16
- data/lib/biodiversity/parser/scientific_name_canonical.rb +0 -528
- data/lib/biodiversity/parser/scientific_name_canonical.treetop +0 -120
- data/lib/biodiversity/parser/scientific_name_clean.rb +0 -8991
- data/lib/biodiversity/parser/scientific_name_clean.treetop +0 -1632
- data/lib/biodiversity/parser/scientific_name_dirty.rb +0 -1298
- data/lib/biodiversity/parser/scientific_name_dirty.treetop +0 -264
- data/spec/biodiversity_spec.rb +0 -11
- data/spec/files/test_data.txt +0 -490
- data/spec/files/todo.txt +0 -55
- data/spec/guid/lsid.spec.rb +0 -15
- data/spec/parser/scientific_name_canonical_spec.rb +0 -36
- data/spec/parser/scientific_name_clean_spec.rb +0 -1137
- data/spec/parser/scientific_name_dirty_spec.rb +0 -165
- data/spec/parser/scientific_name_spec.rb +0 -193
@@ -1,528 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# Autogenerated from a Treetop grammar. Edits may be lost.
|
3
|
-
|
4
|
-
|
5
|
-
module ScientificNameCanonical
|
6
|
-
include Treetop::Runtime
|
7
|
-
|
8
|
-
def root
|
9
|
-
@root ||= :root
|
10
|
-
end
|
11
|
-
|
12
|
-
include ScientificNameDirty
|
13
|
-
|
14
|
-
module Root0
|
15
|
-
def hybrid
|
16
|
-
false
|
17
|
-
end
|
18
|
-
|
19
|
-
def details
|
20
|
-
[super]
|
21
|
-
end
|
22
|
-
|
23
|
-
def parser_run
|
24
|
-
3
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
module Root1
|
29
|
-
def hybrid
|
30
|
-
false
|
31
|
-
end
|
32
|
-
|
33
|
-
def details
|
34
|
-
[super]
|
35
|
-
end
|
36
|
-
|
37
|
-
def parser_run
|
38
|
-
3
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def _nt_root
|
43
|
-
start_index = index
|
44
|
-
if node_cache[:root].has_key?(index)
|
45
|
-
cached = node_cache[:root][index]
|
46
|
-
if cached
|
47
|
-
node_cache[:root][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
48
|
-
@index = cached.interval.end
|
49
|
-
end
|
50
|
-
return cached
|
51
|
-
end
|
52
|
-
|
53
|
-
i0 = index
|
54
|
-
r1 = _nt_multinomial_with_garbage
|
55
|
-
r1.extend(Root0)
|
56
|
-
r1.extend(Root0)
|
57
|
-
if r1
|
58
|
-
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
59
|
-
r0 = r1
|
60
|
-
else
|
61
|
-
r2 = _nt_uninomial_with_garbage
|
62
|
-
r2.extend(Root1)
|
63
|
-
r2.extend(Root1)
|
64
|
-
if r2
|
65
|
-
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
66
|
-
r0 = r2
|
67
|
-
else
|
68
|
-
@index = i0
|
69
|
-
r0 = nil
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
node_cache[:root][start_index] = r0
|
74
|
-
|
75
|
-
r0
|
76
|
-
end
|
77
|
-
|
78
|
-
module MultinomialWithGarbage0
|
79
|
-
def a
|
80
|
-
elements[0]
|
81
|
-
end
|
82
|
-
|
83
|
-
def space1
|
84
|
-
elements[1]
|
85
|
-
end
|
86
|
-
|
87
|
-
def b
|
88
|
-
elements[2]
|
89
|
-
end
|
90
|
-
|
91
|
-
def space2
|
92
|
-
elements[3]
|
93
|
-
end
|
94
|
-
|
95
|
-
def c
|
96
|
-
elements[4]
|
97
|
-
end
|
98
|
-
|
99
|
-
def garbage
|
100
|
-
elements[5]
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
module MultinomialWithGarbage1
|
105
|
-
def value
|
106
|
-
a.value + " " + b.value + " " + c.value
|
107
|
-
end
|
108
|
-
|
109
|
-
def canonical
|
110
|
-
a.canonical + " " + c.canonical
|
111
|
-
end
|
112
|
-
|
113
|
-
def pos
|
114
|
-
a.pos.merge(b.pos).merge(c.pos)
|
115
|
-
end
|
116
|
-
|
117
|
-
def details
|
118
|
-
a.details.merge(b.details).merge(c.details)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
module MultinomialWithGarbage2
|
123
|
-
def a
|
124
|
-
elements[0]
|
125
|
-
end
|
126
|
-
|
127
|
-
def space
|
128
|
-
elements[1]
|
129
|
-
end
|
130
|
-
|
131
|
-
def b
|
132
|
-
elements[2]
|
133
|
-
end
|
134
|
-
|
135
|
-
def garbage
|
136
|
-
elements[3]
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
module MultinomialWithGarbage3
|
141
|
-
def value
|
142
|
-
a.value + " " + b.value
|
143
|
-
end
|
144
|
-
|
145
|
-
def canonical
|
146
|
-
a.canonical
|
147
|
-
end
|
148
|
-
|
149
|
-
def pos
|
150
|
-
a.pos.merge(b.pos)
|
151
|
-
end
|
152
|
-
|
153
|
-
def details
|
154
|
-
a.details.merge(b.details)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
module MultinomialWithGarbage4
|
159
|
-
def a
|
160
|
-
elements[0]
|
161
|
-
end
|
162
|
-
|
163
|
-
def space
|
164
|
-
elements[1]
|
165
|
-
end
|
166
|
-
|
167
|
-
def b
|
168
|
-
elements[2]
|
169
|
-
end
|
170
|
-
|
171
|
-
def garbage
|
172
|
-
elements[3]
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
module MultinomialWithGarbage5
|
177
|
-
def value
|
178
|
-
a.value + " " + b.value
|
179
|
-
end
|
180
|
-
|
181
|
-
def canonical
|
182
|
-
a.canonical + " " + b.canonical
|
183
|
-
end
|
184
|
-
|
185
|
-
def pos
|
186
|
-
a.pos.merge(b.pos)
|
187
|
-
end
|
188
|
-
|
189
|
-
def details
|
190
|
-
a.details.merge(b.details)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def _nt_multinomial_with_garbage
|
195
|
-
start_index = index
|
196
|
-
if node_cache[:multinomial_with_garbage].has_key?(index)
|
197
|
-
cached = node_cache[:multinomial_with_garbage][index]
|
198
|
-
if cached
|
199
|
-
node_cache[:multinomial_with_garbage][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
200
|
-
@index = cached.interval.end
|
201
|
-
end
|
202
|
-
return cached
|
203
|
-
end
|
204
|
-
|
205
|
-
i0 = index
|
206
|
-
i1, s1 = index, []
|
207
|
-
r2 = _nt_genus
|
208
|
-
s1 << r2
|
209
|
-
if r2
|
210
|
-
r3 = _nt_space
|
211
|
-
s1 << r3
|
212
|
-
if r3
|
213
|
-
r4 = _nt_infragenus
|
214
|
-
s1 << r4
|
215
|
-
if r4
|
216
|
-
r5 = _nt_space
|
217
|
-
s1 << r5
|
218
|
-
if r5
|
219
|
-
r6 = _nt_species
|
220
|
-
s1 << r6
|
221
|
-
if r6
|
222
|
-
r7 = _nt_garbage
|
223
|
-
s1 << r7
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
if s1.last
|
230
|
-
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
231
|
-
r1.extend(MultinomialWithGarbage0)
|
232
|
-
r1.extend(MultinomialWithGarbage1)
|
233
|
-
else
|
234
|
-
@index = i1
|
235
|
-
r1 = nil
|
236
|
-
end
|
237
|
-
if r1
|
238
|
-
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
239
|
-
r0 = r1
|
240
|
-
else
|
241
|
-
i8, s8 = index, []
|
242
|
-
r9 = _nt_genus
|
243
|
-
s8 << r9
|
244
|
-
if r9
|
245
|
-
r10 = _nt_space
|
246
|
-
s8 << r10
|
247
|
-
if r10
|
248
|
-
r11 = _nt_infragenus
|
249
|
-
s8 << r11
|
250
|
-
if r11
|
251
|
-
r12 = _nt_garbage
|
252
|
-
s8 << r12
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
if s8.last
|
257
|
-
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
258
|
-
r8.extend(MultinomialWithGarbage2)
|
259
|
-
r8.extend(MultinomialWithGarbage3)
|
260
|
-
else
|
261
|
-
@index = i8
|
262
|
-
r8 = nil
|
263
|
-
end
|
264
|
-
if r8
|
265
|
-
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
266
|
-
r0 = r8
|
267
|
-
else
|
268
|
-
i13, s13 = index, []
|
269
|
-
r14 = _nt_genus
|
270
|
-
s13 << r14
|
271
|
-
if r14
|
272
|
-
r15 = _nt_space
|
273
|
-
s13 << r15
|
274
|
-
if r15
|
275
|
-
r16 = _nt_species
|
276
|
-
s13 << r16
|
277
|
-
if r16
|
278
|
-
r17 = _nt_garbage
|
279
|
-
s13 << r17
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
if s13.last
|
284
|
-
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
285
|
-
r13.extend(MultinomialWithGarbage4)
|
286
|
-
r13.extend(MultinomialWithGarbage5)
|
287
|
-
else
|
288
|
-
@index = i13
|
289
|
-
r13 = nil
|
290
|
-
end
|
291
|
-
if r13
|
292
|
-
r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
|
293
|
-
r0 = r13
|
294
|
-
else
|
295
|
-
@index = i0
|
296
|
-
r0 = nil
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
|
-
node_cache[:multinomial_with_garbage][start_index] = r0
|
302
|
-
|
303
|
-
r0
|
304
|
-
end
|
305
|
-
|
306
|
-
module UninomialWithGarbage0
|
307
|
-
def a
|
308
|
-
elements[0]
|
309
|
-
end
|
310
|
-
|
311
|
-
def b
|
312
|
-
elements[1]
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
module UninomialWithGarbage1
|
317
|
-
def value
|
318
|
-
a.value
|
319
|
-
end
|
320
|
-
|
321
|
-
def canonical
|
322
|
-
a.canonical
|
323
|
-
end
|
324
|
-
|
325
|
-
def pos
|
326
|
-
a.pos
|
327
|
-
end
|
328
|
-
|
329
|
-
def details
|
330
|
-
{:uninomial => a.details[:uninomial]}
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
def _nt_uninomial_with_garbage
|
335
|
-
start_index = index
|
336
|
-
if node_cache[:uninomial_with_garbage].has_key?(index)
|
337
|
-
cached = node_cache[:uninomial_with_garbage][index]
|
338
|
-
if cached
|
339
|
-
node_cache[:uninomial_with_garbage][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
340
|
-
@index = cached.interval.end
|
341
|
-
end
|
342
|
-
return cached
|
343
|
-
end
|
344
|
-
|
345
|
-
i0, s0 = index, []
|
346
|
-
r1 = _nt_uninomial_string
|
347
|
-
s0 << r1
|
348
|
-
if r1
|
349
|
-
r2 = _nt_garbage
|
350
|
-
s0 << r2
|
351
|
-
end
|
352
|
-
if s0.last
|
353
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
354
|
-
r0.extend(UninomialWithGarbage0)
|
355
|
-
r0.extend(UninomialWithGarbage1)
|
356
|
-
else
|
357
|
-
@index = i0
|
358
|
-
r0 = nil
|
359
|
-
end
|
360
|
-
|
361
|
-
node_cache[:uninomial_with_garbage][start_index] = r0
|
362
|
-
|
363
|
-
r0
|
364
|
-
end
|
365
|
-
|
366
|
-
module Garbage0
|
367
|
-
def space
|
368
|
-
elements[0]
|
369
|
-
end
|
370
|
-
|
371
|
-
end
|
372
|
-
|
373
|
-
module Garbage1
|
374
|
-
def space1
|
375
|
-
elements[0]
|
376
|
-
end
|
377
|
-
|
378
|
-
def space2
|
379
|
-
elements[2]
|
380
|
-
end
|
381
|
-
|
382
|
-
end
|
383
|
-
|
384
|
-
module Garbage2
|
385
|
-
def space_hard
|
386
|
-
elements[0]
|
387
|
-
end
|
388
|
-
|
389
|
-
end
|
390
|
-
|
391
|
-
def _nt_garbage
|
392
|
-
start_index = index
|
393
|
-
if node_cache[:garbage].has_key?(index)
|
394
|
-
cached = node_cache[:garbage][index]
|
395
|
-
if cached
|
396
|
-
node_cache[:garbage][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
397
|
-
@index = cached.interval.end
|
398
|
-
end
|
399
|
-
return cached
|
400
|
-
end
|
401
|
-
|
402
|
-
i0 = index
|
403
|
-
i1, s1 = index, []
|
404
|
-
r2 = _nt_space
|
405
|
-
s1 << r2
|
406
|
-
if r2
|
407
|
-
if (match_len = has_terminal?("$$g@rbg3$$", false, index))
|
408
|
-
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
409
|
-
@index += match_len
|
410
|
-
else
|
411
|
-
terminal_parse_failure('"$$g@rbg3$$"')
|
412
|
-
r3 = nil
|
413
|
-
end
|
414
|
-
s1 << r3
|
415
|
-
end
|
416
|
-
if s1.last
|
417
|
-
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
418
|
-
r1.extend(Garbage0)
|
419
|
-
else
|
420
|
-
@index = i1
|
421
|
-
r1 = nil
|
422
|
-
end
|
423
|
-
if r1
|
424
|
-
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
425
|
-
r0 = r1
|
426
|
-
else
|
427
|
-
i4, s4 = index, []
|
428
|
-
r5 = _nt_space
|
429
|
-
s4 << r5
|
430
|
-
if r5
|
431
|
-
if has_terminal?(@regexps[gr = '\A["\',.]'] ||= Regexp.new(gr), :regexp, index)
|
432
|
-
r6 = true
|
433
|
-
@index += 1
|
434
|
-
else
|
435
|
-
terminal_parse_failure('["\',.]')
|
436
|
-
r6 = nil
|
437
|
-
end
|
438
|
-
s4 << r6
|
439
|
-
if r6
|
440
|
-
r7 = _nt_space
|
441
|
-
s4 << r7
|
442
|
-
if r7
|
443
|
-
s8, i8 = [], index
|
444
|
-
loop do
|
445
|
-
if has_terminal?(@regexps[gr = '\A[^щ]'] ||= Regexp.new(gr), :regexp, index)
|
446
|
-
r9 = true
|
447
|
-
@index += 1
|
448
|
-
else
|
449
|
-
terminal_parse_failure('[^щ]')
|
450
|
-
r9 = nil
|
451
|
-
end
|
452
|
-
if r9
|
453
|
-
s8 << r9
|
454
|
-
else
|
455
|
-
break
|
456
|
-
end
|
457
|
-
end
|
458
|
-
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
459
|
-
s4 << r8
|
460
|
-
end
|
461
|
-
end
|
462
|
-
end
|
463
|
-
if s4.last
|
464
|
-
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
465
|
-
r4.extend(Garbage1)
|
466
|
-
else
|
467
|
-
@index = i4
|
468
|
-
r4 = nil
|
469
|
-
end
|
470
|
-
if r4
|
471
|
-
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
472
|
-
r0 = r4
|
473
|
-
else
|
474
|
-
i10, s10 = index, []
|
475
|
-
r11 = _nt_space_hard
|
476
|
-
s10 << r11
|
477
|
-
if r11
|
478
|
-
s12, i12 = [], index
|
479
|
-
loop do
|
480
|
-
if has_terminal?(@regexps[gr = '\A[^ш]'] ||= Regexp.new(gr), :regexp, index)
|
481
|
-
r13 = true
|
482
|
-
@index += 1
|
483
|
-
else
|
484
|
-
terminal_parse_failure('[^ш]')
|
485
|
-
r13 = nil
|
486
|
-
end
|
487
|
-
if r13
|
488
|
-
s12 << r13
|
489
|
-
else
|
490
|
-
break
|
491
|
-
end
|
492
|
-
end
|
493
|
-
if s12.empty?
|
494
|
-
@index = i12
|
495
|
-
r12 = nil
|
496
|
-
else
|
497
|
-
r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
|
498
|
-
end
|
499
|
-
s10 << r12
|
500
|
-
end
|
501
|
-
if s10.last
|
502
|
-
r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
|
503
|
-
r10.extend(Garbage2)
|
504
|
-
else
|
505
|
-
@index = i10
|
506
|
-
r10 = nil
|
507
|
-
end
|
508
|
-
if r10
|
509
|
-
r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
|
510
|
-
r0 = r10
|
511
|
-
else
|
512
|
-
@index = i0
|
513
|
-
r0 = nil
|
514
|
-
end
|
515
|
-
end
|
516
|
-
end
|
517
|
-
|
518
|
-
node_cache[:garbage][start_index] = r0
|
519
|
-
|
520
|
-
r0
|
521
|
-
end
|
522
|
-
|
523
|
-
end
|
524
|
-
|
525
|
-
class ScientificNameCanonicalParser < Treetop::Runtime::CompiledParser
|
526
|
-
include ScientificNameCanonical
|
527
|
-
end
|
528
|
-
|