biodiversity19 0.5.15
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +13 -0
- data/LICENSE +20 -0
- data/README.rdoc +44 -0
- data/Rakefile +43 -0
- data/VERSION +1 -0
- data/bin/nnparse +43 -0
- data/bin/parserver +14 -0
- data/biodiversity.gemspec +85 -0
- data/conf/environment.rb +3 -0
- data/lib/biodiversity/guid/lsid.rb +18 -0
- data/lib/biodiversity/guid.rb +2 -0
- data/lib/biodiversity/parser/scientific_name_canonical.rb +475 -0
- data/lib/biodiversity/parser/scientific_name_canonical.treetop +111 -0
- data/lib/biodiversity/parser/scientific_name_clean.rb +6142 -0
- data/lib/biodiversity/parser/scientific_name_clean.treetop +1195 -0
- data/lib/biodiversity/parser/scientific_name_dirty.rb +1096 -0
- data/lib/biodiversity/parser/scientific_name_dirty.treetop +211 -0
- data/lib/biodiversity/parser.rb +57 -0
- data/lib/biodiversity.rb +9 -0
- data/pkg/.gitignore +0 -0
- data/spec/biodiversity_spec.rb +0 -0
- data/spec/guid/lsid.spec.rb +12 -0
- data/spec/parser/scientific_name.spec.rb +35 -0
- data/spec/parser/scientific_name_canonical.spec.rb +27 -0
- data/spec/parser/scientific_name_clean.spec.rb +504 -0
- data/spec/parser/scientific_name_dirty.spec.rb +90 -0
- data/spec/parser/spec_helper.rb +69 -0
- data/spec/parser/test_data.txt +235 -0
- data/spec/spec_helper.rb +0 -0
- metadata +122 -0
@@ -0,0 +1,1096 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
module ScientificNameDirty
|
3
|
+
include Treetop::Runtime
|
4
|
+
|
5
|
+
def root
|
6
|
+
@root || :root
|
7
|
+
end
|
8
|
+
|
9
|
+
include ScientificNameClean
|
10
|
+
|
11
|
+
def _nt_root
|
12
|
+
start_index = index
|
13
|
+
if node_cache[:root].has_key?(index)
|
14
|
+
cached = node_cache[:root][index]
|
15
|
+
if cached
|
16
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
17
|
+
@index = cached.interval.end
|
18
|
+
end
|
19
|
+
return cached
|
20
|
+
end
|
21
|
+
|
22
|
+
r0 = super
|
23
|
+
|
24
|
+
node_cache[:root][start_index] = r0
|
25
|
+
|
26
|
+
r0
|
27
|
+
end
|
28
|
+
|
29
|
+
module ScientificName50
|
30
|
+
def a
|
31
|
+
elements[0]
|
32
|
+
end
|
33
|
+
|
34
|
+
def garbage
|
35
|
+
elements[1]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
module ScientificName51
|
40
|
+
def value
|
41
|
+
a.value
|
42
|
+
end
|
43
|
+
|
44
|
+
def canonical
|
45
|
+
a.canonical
|
46
|
+
end
|
47
|
+
|
48
|
+
def pos
|
49
|
+
a.pos
|
50
|
+
end
|
51
|
+
|
52
|
+
def details
|
53
|
+
a.details
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def _nt_scientific_name_5
|
58
|
+
start_index = index
|
59
|
+
if node_cache[:scientific_name_5].has_key?(index)
|
60
|
+
cached = node_cache[:scientific_name_5][index]
|
61
|
+
if cached
|
62
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
63
|
+
@index = cached.interval.end
|
64
|
+
end
|
65
|
+
return cached
|
66
|
+
end
|
67
|
+
|
68
|
+
i0 = index
|
69
|
+
i1, s1 = index, []
|
70
|
+
r2 = _nt_scientific_name_4
|
71
|
+
s1 << r2
|
72
|
+
if r2
|
73
|
+
r3 = _nt_garbage
|
74
|
+
s1 << r3
|
75
|
+
end
|
76
|
+
if s1.last
|
77
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
78
|
+
r1.extend(ScientificName50)
|
79
|
+
r1.extend(ScientificName51)
|
80
|
+
else
|
81
|
+
@index = i1
|
82
|
+
r1 = nil
|
83
|
+
end
|
84
|
+
if r1
|
85
|
+
r0 = r1
|
86
|
+
else
|
87
|
+
r4 = super
|
88
|
+
if r4
|
89
|
+
r0 = r4
|
90
|
+
else
|
91
|
+
@index = i0
|
92
|
+
r0 = nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
node_cache[:scientific_name_5][start_index] = r0
|
97
|
+
|
98
|
+
r0
|
99
|
+
end
|
100
|
+
|
101
|
+
module Infraspecies0
|
102
|
+
def a
|
103
|
+
elements[0]
|
104
|
+
end
|
105
|
+
|
106
|
+
def space
|
107
|
+
elements[1]
|
108
|
+
end
|
109
|
+
|
110
|
+
def b
|
111
|
+
elements[2]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
module Infraspecies1
|
116
|
+
def value
|
117
|
+
a.value + " " + b.value
|
118
|
+
end
|
119
|
+
|
120
|
+
def canonical
|
121
|
+
a.canonical
|
122
|
+
end
|
123
|
+
|
124
|
+
def pos
|
125
|
+
a.pos.merge(b.pos)
|
126
|
+
end
|
127
|
+
|
128
|
+
def details
|
129
|
+
{:infraspecies => a.details[:infraspecies].merge(b.details)}
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
module Infraspecies2
|
134
|
+
def a
|
135
|
+
elements[0]
|
136
|
+
end
|
137
|
+
|
138
|
+
def space1
|
139
|
+
elements[1]
|
140
|
+
end
|
141
|
+
|
142
|
+
def string_authorship_inconsistencies
|
143
|
+
elements[2]
|
144
|
+
end
|
145
|
+
|
146
|
+
def space2
|
147
|
+
elements[3]
|
148
|
+
end
|
149
|
+
|
150
|
+
def b
|
151
|
+
elements[4]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
module Infraspecies3
|
156
|
+
def value
|
157
|
+
a.value + " " + b.value
|
158
|
+
end
|
159
|
+
|
160
|
+
def canonical
|
161
|
+
a.canonical
|
162
|
+
end
|
163
|
+
|
164
|
+
def pos
|
165
|
+
a.pos.merge(b.pos)
|
166
|
+
end
|
167
|
+
|
168
|
+
def details
|
169
|
+
{:infraspecies => a.details[:infraspecies].merge(b.details)}
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def _nt_infraspecies
|
174
|
+
start_index = index
|
175
|
+
if node_cache[:infraspecies].has_key?(index)
|
176
|
+
cached = node_cache[:infraspecies][index]
|
177
|
+
if cached
|
178
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
179
|
+
@index = cached.interval.end
|
180
|
+
end
|
181
|
+
return cached
|
182
|
+
end
|
183
|
+
|
184
|
+
i0 = index
|
185
|
+
i1, s1 = index, []
|
186
|
+
r2 = _nt_infraspecies_string
|
187
|
+
s1 << r2
|
188
|
+
if r2
|
189
|
+
r3 = _nt_space
|
190
|
+
s1 << r3
|
191
|
+
if r3
|
192
|
+
r4 = _nt_year
|
193
|
+
s1 << r4
|
194
|
+
end
|
195
|
+
end
|
196
|
+
if s1.last
|
197
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
198
|
+
r1.extend(Infraspecies0)
|
199
|
+
r1.extend(Infraspecies1)
|
200
|
+
else
|
201
|
+
@index = i1
|
202
|
+
r1 = nil
|
203
|
+
end
|
204
|
+
if r1
|
205
|
+
r0 = r1
|
206
|
+
else
|
207
|
+
i5, s5 = index, []
|
208
|
+
r6 = _nt_infraspecies_string
|
209
|
+
s5 << r6
|
210
|
+
if r6
|
211
|
+
r7 = _nt_space
|
212
|
+
s5 << r7
|
213
|
+
if r7
|
214
|
+
r8 = _nt_string_authorship_inconsistencies
|
215
|
+
s5 << r8
|
216
|
+
if r8
|
217
|
+
r9 = _nt_space
|
218
|
+
s5 << r9
|
219
|
+
if r9
|
220
|
+
r10 = _nt_authorship
|
221
|
+
s5 << r10
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
if s5.last
|
227
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
228
|
+
r5.extend(Infraspecies2)
|
229
|
+
r5.extend(Infraspecies3)
|
230
|
+
else
|
231
|
+
@index = i5
|
232
|
+
r5 = nil
|
233
|
+
end
|
234
|
+
if r5
|
235
|
+
r0 = r5
|
236
|
+
else
|
237
|
+
r11 = super
|
238
|
+
if r11
|
239
|
+
r0 = r11
|
240
|
+
else
|
241
|
+
@index = i0
|
242
|
+
r0 = nil
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
node_cache[:infraspecies][start_index] = r0
|
248
|
+
|
249
|
+
r0
|
250
|
+
end
|
251
|
+
|
252
|
+
module Species0
|
253
|
+
def a
|
254
|
+
elements[0]
|
255
|
+
end
|
256
|
+
|
257
|
+
def space
|
258
|
+
elements[1]
|
259
|
+
end
|
260
|
+
|
261
|
+
def b
|
262
|
+
elements[2]
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
module Species1
|
267
|
+
def value
|
268
|
+
a.value + " " + b.value
|
269
|
+
end
|
270
|
+
|
271
|
+
def canonical
|
272
|
+
a.canonical
|
273
|
+
end
|
274
|
+
|
275
|
+
def pos
|
276
|
+
a.pos.merge(b.pos)
|
277
|
+
end
|
278
|
+
|
279
|
+
def details
|
280
|
+
{:species => a.details[:species].merge(b.details)}
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def _nt_species
|
285
|
+
start_index = index
|
286
|
+
if node_cache[:species].has_key?(index)
|
287
|
+
cached = node_cache[:species][index]
|
288
|
+
if cached
|
289
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
290
|
+
@index = cached.interval.end
|
291
|
+
end
|
292
|
+
return cached
|
293
|
+
end
|
294
|
+
|
295
|
+
i0 = index
|
296
|
+
i1, s1 = index, []
|
297
|
+
r2 = _nt_species_string
|
298
|
+
s1 << r2
|
299
|
+
if r2
|
300
|
+
r3 = _nt_space
|
301
|
+
s1 << r3
|
302
|
+
if r3
|
303
|
+
r4 = _nt_year
|
304
|
+
s1 << r4
|
305
|
+
end
|
306
|
+
end
|
307
|
+
if s1.last
|
308
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
309
|
+
r1.extend(Species0)
|
310
|
+
r1.extend(Species1)
|
311
|
+
else
|
312
|
+
@index = i1
|
313
|
+
r1 = nil
|
314
|
+
end
|
315
|
+
if r1
|
316
|
+
r0 = r1
|
317
|
+
else
|
318
|
+
r5 = super
|
319
|
+
if r5
|
320
|
+
r0 = r5
|
321
|
+
else
|
322
|
+
@index = i0
|
323
|
+
r0 = nil
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
node_cache[:species][start_index] = r0
|
328
|
+
|
329
|
+
r0
|
330
|
+
end
|
331
|
+
|
332
|
+
module RightParen0
|
333
|
+
def space
|
334
|
+
elements[1]
|
335
|
+
end
|
336
|
+
|
337
|
+
end
|
338
|
+
|
339
|
+
def _nt_right_paren
|
340
|
+
start_index = index
|
341
|
+
if node_cache[:right_paren].has_key?(index)
|
342
|
+
cached = node_cache[:right_paren][index]
|
343
|
+
if cached
|
344
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
345
|
+
@index = cached.interval.end
|
346
|
+
end
|
347
|
+
return cached
|
348
|
+
end
|
349
|
+
|
350
|
+
i0 = index
|
351
|
+
i1, s1 = index, []
|
352
|
+
if has_terminal?(")", false, index)
|
353
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
354
|
+
@index += 1
|
355
|
+
else
|
356
|
+
terminal_parse_failure(")")
|
357
|
+
r2 = nil
|
358
|
+
end
|
359
|
+
s1 << r2
|
360
|
+
if r2
|
361
|
+
r3 = _nt_space
|
362
|
+
s1 << r3
|
363
|
+
if r3
|
364
|
+
if has_terminal?(")", false, index)
|
365
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
366
|
+
@index += 1
|
367
|
+
else
|
368
|
+
terminal_parse_failure(")")
|
369
|
+
r4 = nil
|
370
|
+
end
|
371
|
+
s1 << r4
|
372
|
+
end
|
373
|
+
end
|
374
|
+
if s1.last
|
375
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
376
|
+
r1.extend(RightParen0)
|
377
|
+
else
|
378
|
+
@index = i1
|
379
|
+
r1 = nil
|
380
|
+
end
|
381
|
+
if r1
|
382
|
+
r0 = r1
|
383
|
+
else
|
384
|
+
r5 = super
|
385
|
+
if r5
|
386
|
+
r0 = r5
|
387
|
+
else
|
388
|
+
@index = i0
|
389
|
+
r0 = nil
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
node_cache[:right_paren][start_index] = r0
|
394
|
+
|
395
|
+
r0
|
396
|
+
end
|
397
|
+
|
398
|
+
module LeftParen0
|
399
|
+
def space
|
400
|
+
elements[1]
|
401
|
+
end
|
402
|
+
|
403
|
+
end
|
404
|
+
|
405
|
+
def _nt_left_paren
|
406
|
+
start_index = index
|
407
|
+
if node_cache[:left_paren].has_key?(index)
|
408
|
+
cached = node_cache[:left_paren][index]
|
409
|
+
if cached
|
410
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
411
|
+
@index = cached.interval.end
|
412
|
+
end
|
413
|
+
return cached
|
414
|
+
end
|
415
|
+
|
416
|
+
i0 = index
|
417
|
+
i1, s1 = index, []
|
418
|
+
if has_terminal?("(", false, index)
|
419
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
420
|
+
@index += 1
|
421
|
+
else
|
422
|
+
terminal_parse_failure("(")
|
423
|
+
r2 = nil
|
424
|
+
end
|
425
|
+
s1 << r2
|
426
|
+
if r2
|
427
|
+
r3 = _nt_space
|
428
|
+
s1 << r3
|
429
|
+
if r3
|
430
|
+
if has_terminal?("(", false, index)
|
431
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
432
|
+
@index += 1
|
433
|
+
else
|
434
|
+
terminal_parse_failure("(")
|
435
|
+
r4 = nil
|
436
|
+
end
|
437
|
+
s1 << r4
|
438
|
+
end
|
439
|
+
end
|
440
|
+
if s1.last
|
441
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
442
|
+
r1.extend(LeftParen0)
|
443
|
+
else
|
444
|
+
@index = i1
|
445
|
+
r1 = nil
|
446
|
+
end
|
447
|
+
if r1
|
448
|
+
r0 = r1
|
449
|
+
else
|
450
|
+
r5 = super
|
451
|
+
if r5
|
452
|
+
r0 = r5
|
453
|
+
else
|
454
|
+
@index = i0
|
455
|
+
r0 = nil
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
node_cache[:left_paren][start_index] = r0
|
460
|
+
|
461
|
+
r0
|
462
|
+
end
|
463
|
+
|
464
|
+
module Year0
|
465
|
+
def a
|
466
|
+
elements[0]
|
467
|
+
end
|
468
|
+
|
469
|
+
def space
|
470
|
+
elements[1]
|
471
|
+
end
|
472
|
+
|
473
|
+
def b
|
474
|
+
elements[2]
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
module Year1
|
479
|
+
def value
|
480
|
+
a.value + " " + b.value
|
481
|
+
end
|
482
|
+
|
483
|
+
def pos
|
484
|
+
a.pos.merge(b.pos)
|
485
|
+
end
|
486
|
+
|
487
|
+
def details
|
488
|
+
{:year => a.value, :approximate_year => b.value}
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
module Year2
|
493
|
+
def a
|
494
|
+
elements[0]
|
495
|
+
end
|
496
|
+
|
497
|
+
def space
|
498
|
+
elements[1]
|
499
|
+
end
|
500
|
+
|
501
|
+
def page_number
|
502
|
+
elements[2]
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
module Year3
|
507
|
+
def value
|
508
|
+
a.text_value
|
509
|
+
end
|
510
|
+
|
511
|
+
def pos
|
512
|
+
{a.interval.begin => ['year', a.interval.end]}
|
513
|
+
end
|
514
|
+
|
515
|
+
def details
|
516
|
+
{:year => value}
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
def _nt_year
|
521
|
+
start_index = index
|
522
|
+
if node_cache[:year].has_key?(index)
|
523
|
+
cached = node_cache[:year][index]
|
524
|
+
if cached
|
525
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
526
|
+
@index = cached.interval.end
|
527
|
+
end
|
528
|
+
return cached
|
529
|
+
end
|
530
|
+
|
531
|
+
i0 = index
|
532
|
+
i1, s1 = index, []
|
533
|
+
r2 = _nt_year_number
|
534
|
+
s1 << r2
|
535
|
+
if r2
|
536
|
+
r3 = _nt_space
|
537
|
+
s1 << r3
|
538
|
+
if r3
|
539
|
+
r4 = _nt_approximate_year
|
540
|
+
s1 << r4
|
541
|
+
end
|
542
|
+
end
|
543
|
+
if s1.last
|
544
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
545
|
+
r1.extend(Year0)
|
546
|
+
r1.extend(Year1)
|
547
|
+
else
|
548
|
+
@index = i1
|
549
|
+
r1 = nil
|
550
|
+
end
|
551
|
+
if r1
|
552
|
+
r0 = r1
|
553
|
+
else
|
554
|
+
i5, s5 = index, []
|
555
|
+
r6 = _nt_year_number
|
556
|
+
s5 << r6
|
557
|
+
if r6
|
558
|
+
r7 = _nt_space
|
559
|
+
s5 << r7
|
560
|
+
if r7
|
561
|
+
r8 = _nt_page_number
|
562
|
+
s5 << r8
|
563
|
+
end
|
564
|
+
end
|
565
|
+
if s5.last
|
566
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
567
|
+
r5.extend(Year2)
|
568
|
+
r5.extend(Year3)
|
569
|
+
else
|
570
|
+
@index = i5
|
571
|
+
r5 = nil
|
572
|
+
end
|
573
|
+
if r5
|
574
|
+
r0 = r5
|
575
|
+
else
|
576
|
+
r9 = _nt_year_number_with_punctuation
|
577
|
+
if r9
|
578
|
+
r0 = r9
|
579
|
+
else
|
580
|
+
r10 = _nt_approximate_year
|
581
|
+
if r10
|
582
|
+
r0 = r10
|
583
|
+
else
|
584
|
+
r11 = _nt_double_year
|
585
|
+
if r11
|
586
|
+
r0 = r11
|
587
|
+
else
|
588
|
+
r12 = super
|
589
|
+
if r12
|
590
|
+
r0 = r12
|
591
|
+
else
|
592
|
+
@index = i0
|
593
|
+
r0 = nil
|
594
|
+
end
|
595
|
+
end
|
596
|
+
end
|
597
|
+
end
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
601
|
+
node_cache[:year][start_index] = r0
|
602
|
+
|
603
|
+
r0
|
604
|
+
end
|
605
|
+
|
606
|
+
module ApproximateYear0
|
607
|
+
def space1
|
608
|
+
elements[1]
|
609
|
+
end
|
610
|
+
|
611
|
+
def a
|
612
|
+
elements[2]
|
613
|
+
end
|
614
|
+
|
615
|
+
def space2
|
616
|
+
elements[3]
|
617
|
+
end
|
618
|
+
|
619
|
+
end
|
620
|
+
|
621
|
+
module ApproximateYear1
|
622
|
+
def value
|
623
|
+
"(" + a.text_value + ")"
|
624
|
+
end
|
625
|
+
|
626
|
+
def pos
|
627
|
+
{a.interval.begin => ['year', a.interval.end]}
|
628
|
+
end
|
629
|
+
|
630
|
+
def details
|
631
|
+
{:approximate_year => value}
|
632
|
+
end
|
633
|
+
end
|
634
|
+
|
635
|
+
def _nt_approximate_year
|
636
|
+
start_index = index
|
637
|
+
if node_cache[:approximate_year].has_key?(index)
|
638
|
+
cached = node_cache[:approximate_year][index]
|
639
|
+
if cached
|
640
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
641
|
+
@index = cached.interval.end
|
642
|
+
end
|
643
|
+
return cached
|
644
|
+
end
|
645
|
+
|
646
|
+
i0, s0 = index, []
|
647
|
+
if has_terminal?("[", false, index)
|
648
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
649
|
+
@index += 1
|
650
|
+
else
|
651
|
+
terminal_parse_failure("[")
|
652
|
+
r1 = nil
|
653
|
+
end
|
654
|
+
s0 << r1
|
655
|
+
if r1
|
656
|
+
r2 = _nt_space
|
657
|
+
s0 << r2
|
658
|
+
if r2
|
659
|
+
r3 = _nt_year_number
|
660
|
+
s0 << r3
|
661
|
+
if r3
|
662
|
+
r4 = _nt_space
|
663
|
+
s0 << r4
|
664
|
+
if r4
|
665
|
+
s5, i5 = [], index
|
666
|
+
loop do
|
667
|
+
if has_terminal?("]", false, index)
|
668
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
669
|
+
@index += 1
|
670
|
+
else
|
671
|
+
terminal_parse_failure("]")
|
672
|
+
r6 = nil
|
673
|
+
end
|
674
|
+
if r6
|
675
|
+
s5 << r6
|
676
|
+
else
|
677
|
+
break
|
678
|
+
end
|
679
|
+
end
|
680
|
+
if s5.empty?
|
681
|
+
@index = i5
|
682
|
+
r5 = nil
|
683
|
+
else
|
684
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
685
|
+
end
|
686
|
+
s0 << r5
|
687
|
+
end
|
688
|
+
end
|
689
|
+
end
|
690
|
+
end
|
691
|
+
if s0.last
|
692
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
693
|
+
r0.extend(ApproximateYear0)
|
694
|
+
r0.extend(ApproximateYear1)
|
695
|
+
else
|
696
|
+
@index = i0
|
697
|
+
r0 = nil
|
698
|
+
end
|
699
|
+
|
700
|
+
node_cache[:approximate_year][start_index] = r0
|
701
|
+
|
702
|
+
r0
|
703
|
+
end
|
704
|
+
|
705
|
+
module DoubleYear0
|
706
|
+
def year_number
|
707
|
+
elements[0]
|
708
|
+
end
|
709
|
+
|
710
|
+
end
|
711
|
+
|
712
|
+
module DoubleYear1
|
713
|
+
def value
|
714
|
+
text_value
|
715
|
+
end
|
716
|
+
|
717
|
+
def pos
|
718
|
+
{interval.begin => ['year', interval.end]}
|
719
|
+
end
|
720
|
+
|
721
|
+
def details
|
722
|
+
{:year => value}
|
723
|
+
end
|
724
|
+
end
|
725
|
+
|
726
|
+
def _nt_double_year
|
727
|
+
start_index = index
|
728
|
+
if node_cache[:double_year].has_key?(index)
|
729
|
+
cached = node_cache[:double_year][index]
|
730
|
+
if cached
|
731
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
732
|
+
@index = cached.interval.end
|
733
|
+
end
|
734
|
+
return cached
|
735
|
+
end
|
736
|
+
|
737
|
+
i0, s0 = index, []
|
738
|
+
r1 = _nt_year_number
|
739
|
+
s0 << r1
|
740
|
+
if r1
|
741
|
+
if has_terminal?("-", false, index)
|
742
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
743
|
+
@index += 1
|
744
|
+
else
|
745
|
+
terminal_parse_failure("-")
|
746
|
+
r2 = nil
|
747
|
+
end
|
748
|
+
s0 << r2
|
749
|
+
if r2
|
750
|
+
s3, i3 = [], index
|
751
|
+
loop do
|
752
|
+
if has_terminal?('\G[0-9]', true, index)
|
753
|
+
r4 = true
|
754
|
+
@index += 1
|
755
|
+
else
|
756
|
+
r4 = nil
|
757
|
+
end
|
758
|
+
if r4
|
759
|
+
s3 << r4
|
760
|
+
else
|
761
|
+
break
|
762
|
+
end
|
763
|
+
end
|
764
|
+
if s3.empty?
|
765
|
+
@index = i3
|
766
|
+
r3 = nil
|
767
|
+
else
|
768
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
769
|
+
end
|
770
|
+
s0 << r3
|
771
|
+
if r3
|
772
|
+
if has_terminal?('\G[A-Za-z]', true, index)
|
773
|
+
r6 = true
|
774
|
+
@index += 1
|
775
|
+
else
|
776
|
+
r6 = nil
|
777
|
+
end
|
778
|
+
if r6
|
779
|
+
r5 = r6
|
780
|
+
else
|
781
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
782
|
+
end
|
783
|
+
s0 << r5
|
784
|
+
if r5
|
785
|
+
if has_terminal?('\G[\\?]', true, index)
|
786
|
+
r8 = true
|
787
|
+
@index += 1
|
788
|
+
else
|
789
|
+
r8 = nil
|
790
|
+
end
|
791
|
+
if r8
|
792
|
+
r7 = r8
|
793
|
+
else
|
794
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
795
|
+
end
|
796
|
+
s0 << r7
|
797
|
+
end
|
798
|
+
end
|
799
|
+
end
|
800
|
+
end
|
801
|
+
if s0.last
|
802
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
803
|
+
r0.extend(DoubleYear0)
|
804
|
+
r0.extend(DoubleYear1)
|
805
|
+
else
|
806
|
+
@index = i0
|
807
|
+
r0 = nil
|
808
|
+
end
|
809
|
+
|
810
|
+
node_cache[:double_year][start_index] = r0
|
811
|
+
|
812
|
+
r0
|
813
|
+
end
|
814
|
+
|
815
|
+
module YearNumberWithPunctuation0
|
816
|
+
def a
|
817
|
+
elements[0]
|
818
|
+
end
|
819
|
+
|
820
|
+
end
|
821
|
+
|
822
|
+
module YearNumberWithPunctuation1
|
823
|
+
def value
|
824
|
+
a.text_value
|
825
|
+
end
|
826
|
+
|
827
|
+
def pos
|
828
|
+
{interval.begin => ['year', interval.end]}
|
829
|
+
end
|
830
|
+
|
831
|
+
def details
|
832
|
+
{:year => value}
|
833
|
+
end
|
834
|
+
end
|
835
|
+
|
836
|
+
def _nt_year_number_with_punctuation
|
837
|
+
start_index = index
|
838
|
+
if node_cache[:year_number_with_punctuation].has_key?(index)
|
839
|
+
cached = node_cache[:year_number_with_punctuation][index]
|
840
|
+
if cached
|
841
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
842
|
+
@index = cached.interval.end
|
843
|
+
end
|
844
|
+
return cached
|
845
|
+
end
|
846
|
+
|
847
|
+
i0, s0 = index, []
|
848
|
+
r1 = _nt_year_number
|
849
|
+
s0 << r1
|
850
|
+
if r1
|
851
|
+
if has_terminal?(".", false, index)
|
852
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
853
|
+
@index += 1
|
854
|
+
else
|
855
|
+
terminal_parse_failure(".")
|
856
|
+
r2 = nil
|
857
|
+
end
|
858
|
+
s0 << r2
|
859
|
+
end
|
860
|
+
if s0.last
|
861
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
862
|
+
r0.extend(YearNumberWithPunctuation0)
|
863
|
+
r0.extend(YearNumberWithPunctuation1)
|
864
|
+
else
|
865
|
+
@index = i0
|
866
|
+
r0 = nil
|
867
|
+
end
|
868
|
+
|
869
|
+
node_cache[:year_number_with_punctuation][start_index] = r0
|
870
|
+
|
871
|
+
r0
|
872
|
+
end
|
873
|
+
|
874
|
+
module PageNumber0
|
875
|
+
def space
|
876
|
+
elements[1]
|
877
|
+
end
|
878
|
+
|
879
|
+
end
|
880
|
+
|
881
|
+
module PageNumber1
|
882
|
+
def value
|
883
|
+
end
|
884
|
+
end
|
885
|
+
|
886
|
+
def _nt_page_number
|
887
|
+
start_index = index
|
888
|
+
if node_cache[:page_number].has_key?(index)
|
889
|
+
cached = node_cache[:page_number][index]
|
890
|
+
if cached
|
891
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
892
|
+
@index = cached.interval.end
|
893
|
+
end
|
894
|
+
return cached
|
895
|
+
end
|
896
|
+
|
897
|
+
i0, s0 = index, []
|
898
|
+
if has_terminal?(":", false, index)
|
899
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
900
|
+
@index += 1
|
901
|
+
else
|
902
|
+
terminal_parse_failure(":")
|
903
|
+
r1 = nil
|
904
|
+
end
|
905
|
+
s0 << r1
|
906
|
+
if r1
|
907
|
+
r2 = _nt_space
|
908
|
+
s0 << r2
|
909
|
+
if r2
|
910
|
+
s3, i3 = [], index
|
911
|
+
loop do
|
912
|
+
if has_terminal?('\G[\\d]', true, index)
|
913
|
+
r4 = true
|
914
|
+
@index += 1
|
915
|
+
else
|
916
|
+
r4 = nil
|
917
|
+
end
|
918
|
+
if r4
|
919
|
+
s3 << r4
|
920
|
+
else
|
921
|
+
break
|
922
|
+
end
|
923
|
+
end
|
924
|
+
if s3.empty?
|
925
|
+
@index = i3
|
926
|
+
r3 = nil
|
927
|
+
else
|
928
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
929
|
+
end
|
930
|
+
s0 << r3
|
931
|
+
end
|
932
|
+
end
|
933
|
+
if s0.last
|
934
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
935
|
+
r0.extend(PageNumber0)
|
936
|
+
r0.extend(PageNumber1)
|
937
|
+
else
|
938
|
+
@index = i0
|
939
|
+
r0 = nil
|
940
|
+
end
|
941
|
+
|
942
|
+
node_cache[:page_number][start_index] = r0
|
943
|
+
|
944
|
+
r0
|
945
|
+
end
|
946
|
+
|
947
|
+
def _nt_string_authorship_inconsistencies
|
948
|
+
start_index = index
|
949
|
+
if node_cache[:string_authorship_inconsistencies].has_key?(index)
|
950
|
+
cached = node_cache[:string_authorship_inconsistencies][index]
|
951
|
+
if cached
|
952
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
953
|
+
@index = cached.interval.end
|
954
|
+
end
|
955
|
+
return cached
|
956
|
+
end
|
957
|
+
|
958
|
+
if has_terminal?("corrig.", false, index)
|
959
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 7))
|
960
|
+
@index += 7
|
961
|
+
else
|
962
|
+
terminal_parse_failure("corrig.")
|
963
|
+
r0 = nil
|
964
|
+
end
|
965
|
+
|
966
|
+
node_cache[:string_authorship_inconsistencies][start_index] = r0
|
967
|
+
|
968
|
+
r0
|
969
|
+
end
|
970
|
+
|
971
|
+
module Garbage0
|
972
|
+
def space1
|
973
|
+
elements[0]
|
974
|
+
end
|
975
|
+
|
976
|
+
def space2
|
977
|
+
elements[2]
|
978
|
+
end
|
979
|
+
|
980
|
+
end
|
981
|
+
|
982
|
+
module Garbage1
|
983
|
+
def space_hard
|
984
|
+
elements[0]
|
985
|
+
end
|
986
|
+
|
987
|
+
end
|
988
|
+
|
989
|
+
def _nt_garbage
|
990
|
+
start_index = index
|
991
|
+
if node_cache[:garbage].has_key?(index)
|
992
|
+
cached = node_cache[:garbage][index]
|
993
|
+
if cached
|
994
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
995
|
+
@index = cached.interval.end
|
996
|
+
end
|
997
|
+
return cached
|
998
|
+
end
|
999
|
+
|
1000
|
+
i0 = index
|
1001
|
+
i1, s1 = index, []
|
1002
|
+
r2 = _nt_space
|
1003
|
+
s1 << r2
|
1004
|
+
if r2
|
1005
|
+
if has_terminal?('\G["\',.]', true, index)
|
1006
|
+
r3 = true
|
1007
|
+
@index += 1
|
1008
|
+
else
|
1009
|
+
r3 = nil
|
1010
|
+
end
|
1011
|
+
s1 << r3
|
1012
|
+
if r3
|
1013
|
+
r4 = _nt_space
|
1014
|
+
s1 << r4
|
1015
|
+
if r4
|
1016
|
+
s5, i5 = [], index
|
1017
|
+
loop do
|
1018
|
+
if has_terminal?('\G[^щ]', true, index)
|
1019
|
+
r6 = true
|
1020
|
+
@index += 1
|
1021
|
+
else
|
1022
|
+
r6 = nil
|
1023
|
+
end
|
1024
|
+
if r6
|
1025
|
+
s5 << r6
|
1026
|
+
else
|
1027
|
+
break
|
1028
|
+
end
|
1029
|
+
end
|
1030
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
1031
|
+
s1 << r5
|
1032
|
+
end
|
1033
|
+
end
|
1034
|
+
end
|
1035
|
+
if s1.last
|
1036
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1037
|
+
r1.extend(Garbage0)
|
1038
|
+
else
|
1039
|
+
@index = i1
|
1040
|
+
r1 = nil
|
1041
|
+
end
|
1042
|
+
if r1
|
1043
|
+
r0 = r1
|
1044
|
+
else
|
1045
|
+
i7, s7 = index, []
|
1046
|
+
r8 = _nt_space_hard
|
1047
|
+
s7 << r8
|
1048
|
+
if r8
|
1049
|
+
s9, i9 = [], index
|
1050
|
+
loop do
|
1051
|
+
if has_terminal?('\G[^ш]', true, index)
|
1052
|
+
r10 = true
|
1053
|
+
@index += 1
|
1054
|
+
else
|
1055
|
+
r10 = nil
|
1056
|
+
end
|
1057
|
+
if r10
|
1058
|
+
s9 << r10
|
1059
|
+
else
|
1060
|
+
break
|
1061
|
+
end
|
1062
|
+
end
|
1063
|
+
if s9.empty?
|
1064
|
+
@index = i9
|
1065
|
+
r9 = nil
|
1066
|
+
else
|
1067
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
1068
|
+
end
|
1069
|
+
s7 << r9
|
1070
|
+
end
|
1071
|
+
if s7.last
|
1072
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
1073
|
+
r7.extend(Garbage1)
|
1074
|
+
else
|
1075
|
+
@index = i7
|
1076
|
+
r7 = nil
|
1077
|
+
end
|
1078
|
+
if r7
|
1079
|
+
r0 = r7
|
1080
|
+
else
|
1081
|
+
@index = i0
|
1082
|
+
r0 = nil
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
node_cache[:garbage][start_index] = r0
|
1087
|
+
|
1088
|
+
r0
|
1089
|
+
end
|
1090
|
+
|
1091
|
+
end
|
1092
|
+
|
1093
|
+
class ScientificNameDirtyParser < Treetop::Runtime::CompiledParser
|
1094
|
+
include ScientificNameDirty
|
1095
|
+
end
|
1096
|
+
|