Module: ScientificNameCanonical

Includes:
ScientificNameDirty, Treetop::Runtime
Included in:
ScientificNameCanonicalParser
Defined in:
lib/biodiversity/parser/scientific_name_canonical.rb

Defined Under Namespace

Modules: Garbage0, Garbage1, Garbage2, MultinomialWithGarbage0, MultinomialWithGarbage1, MultinomialWithGarbage2, MultinomialWithGarbage3, MultinomialWithGarbage4, MultinomialWithGarbage5, Root0, Root1, UninomialWithGarbage0, UninomialWithGarbage1

Instance Method Summary collapse

Methods included from ScientificNameDirty

#_nt_approximate_year, #_nt_double_year, #_nt_infraspecies, #_nt_latin_word, #_nt_left_paren, #_nt_page_number, #_nt_right_paren, #_nt_scientific_name_5, #_nt_species, #_nt_string_authorship_inconsistencies, #_nt_valid_name_letters, #_nt_year, #_nt_year_number_with_punctuation

Methods included from ScientificNameClean

#_nt_abbreviated_genus, #_nt_annotation_identification, #_nt_author_filius, #_nt_author_maybe_filius, #_nt_author_name, #_nt_author_name_without_postfix, #_nt_author_prefix_word, #_nt_author_separator, #_nt_author_word, #_nt_authors_names, #_nt_authorship, #_nt_basionym_authorship_with_parenthesis, #_nt_cap_digraph, #_nt_cap_latin_word, #_nt_cap_latin_word_pair, #_nt_capped_dotted_char, #_nt_emend, #_nt_emend_authorship, #_nt_ex_authorship, #_nt_ex_sep, #_nt_genus, #_nt_hybrid_character, #_nt_infragenus, #_nt_infraspecies, #_nt_infraspecies_mult, #_nt_infraspecies_string, #_nt_latin_word, #_nt_left_paren, #_nt_multinomial_name, #_nt_multiplication_sign, #_nt_multiuninomial_name, #_nt_rank, #_nt_rank_uninomial, #_nt_right_paren, #_nt_scientific_name_1, #_nt_scientific_name_2, #_nt_scientific_name_3, #_nt_scientific_name_4, #_nt_scientific_name_5, #_nt_simple_authorship, #_nt_space, #_nt_space_hard, #_nt_species, #_nt_species_string, #_nt_species_word, #_nt_species_word_hybrid, #_nt_status_part, #_nt_status_word, #_nt_taxon_concept_rank, #_nt_uninomial_name, #_nt_uninomial_string, #_nt_unknown_auth, #_nt_unparsed, #_nt_valid_name_letter, #_nt_valid_name_letters, #_nt_year, #_nt_year_number, #_nt_year_number_with_character

Instance Method Details

#_nt_garbageObject



391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 391

def _nt_garbage
  start_index = index
  if node_cache[:garbage].has_key?(index)
    cached = node_cache[:garbage][index]
    if cached
      node_cache[:garbage][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  i1, s1 = index, []
  r2 = _nt_space
  s1 << r2
  if r2
    if (match_len = has_terminal?("$$g@rbg3$$", false, index))
      r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
      @index += match_len
    else
      terminal_parse_failure('"$$g@rbg3$$"')
      r3 = nil
    end
    s1 << r3
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(Garbage0)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    i4, s4 = index, []
    r5 = _nt_space
    s4 << r5
    if r5
      if has_terminal?(@regexps[gr = '\A["\',.]'] ||= Regexp.new(gr), :regexp, index)
        r6 = true
        @index += 1
      else
        terminal_parse_failure('["\',.]')
        r6 = nil
      end
      s4 << r6
      if r6
        r7 = _nt_space
        s4 << r7
        if r7
          s8, i8 = [], index
          loop do
            if has_terminal?(@regexps[gr = '\A[^щ]'] ||= Regexp.new(gr), :regexp, index)
              r9 = true
              @index += 1
            else
              terminal_parse_failure('[^щ]')
              r9 = nil
            end
            if r9
              s8 << r9
            else
              break
            end
          end
          r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
          s4 << r8
        end
      end
    end
    if s4.last
      r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
      r4.extend(Garbage1)
    else
      @index = i4
      r4 = nil
    end
    if r4
      r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
      r0 = r4
    else
      i10, s10 = index, []
      r11 = _nt_space_hard
      s10 << r11
      if r11
        s12, i12 = [], index
        loop do
          if has_terminal?(@regexps[gr = '\A[^ш]'] ||= Regexp.new(gr), :regexp, index)
            r13 = true
            @index += 1
          else
            terminal_parse_failure('[^ш]')
            r13 = nil
          end
          if r13
            s12 << r13
          else
            break
          end
        end
        if s12.empty?
          @index = i12
          r12 = nil
        else
          r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
        end
        s10 << r12
      end
      if s10.last
        r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
        r10.extend(Garbage2)
      else
        @index = i10
        r10 = nil
      end
      if r10
        r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
        r0 = r10
      else
        @index = i0
        r0 = nil
      end
    end
  end

  node_cache[:garbage][start_index] = r0

  r0
end

#_nt_multinomial_with_garbageObject



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 194

def _nt_multinomial_with_garbage
  start_index = index
  if node_cache[:multinomial_with_garbage].has_key?(index)
    cached = node_cache[:multinomial_with_garbage][index]
    if cached
      node_cache[:multinomial_with_garbage][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  i1, s1 = index, []
  r2 = _nt_genus
  s1 << r2
  if r2
    r3 = _nt_space
    s1 << r3
    if r3
      r4 = _nt_infragenus
      s1 << r4
      if r4
        r5 = _nt_space
        s1 << r5
        if r5
          r6 = _nt_species
          s1 << r6
          if r6
            r7 = _nt_garbage
            s1 << r7
          end
        end
      end
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(MultinomialWithGarbage0)
    r1.extend(MultinomialWithGarbage1)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    i8, s8 = index, []
    r9 = _nt_genus
    s8 << r9
    if r9
      r10 = _nt_space
      s8 << r10
      if r10
        r11 = _nt_infragenus
        s8 << r11
        if r11
          r12 = _nt_garbage
          s8 << r12
        end
      end
    end
    if s8.last
      r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
      r8.extend(MultinomialWithGarbage2)
      r8.extend(MultinomialWithGarbage3)
    else
      @index = i8
      r8 = nil
    end
    if r8
      r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
      r0 = r8
    else
      i13, s13 = index, []
      r14 = _nt_genus
      s13 << r14
      if r14
        r15 = _nt_space
        s13 << r15
        if r15
          r16 = _nt_species
          s13 << r16
          if r16
            r17 = _nt_garbage
            s13 << r17
          end
        end
      end
      if s13.last
        r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
        r13.extend(MultinomialWithGarbage4)
        r13.extend(MultinomialWithGarbage5)
      else
        @index = i13
        r13 = nil
      end
      if r13
        r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
        r0 = r13
      else
        @index = i0
        r0 = nil
      end
    end
  end

  node_cache[:multinomial_with_garbage][start_index] = r0

  r0
end

#_nt_rootObject



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
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 42

def _nt_root
  start_index = index
  if node_cache[:root].has_key?(index)
    cached = node_cache[:root][index]
    if cached
      node_cache[:root][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  r1 = _nt_multinomial_with_garbage
  r1.extend(Root0)
  r1.extend(Root0)
  if r1
    r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
    r0 = r1
  else
    r2 = _nt_uninomial_with_garbage
    r2.extend(Root1)
    r2.extend(Root1)
    if r2
      r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
      r0 = r2
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:root][start_index] = r0

  r0
end

#_nt_uninomial_with_garbageObject



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 334

def _nt_uninomial_with_garbage
  start_index = index
  if node_cache[:uninomial_with_garbage].has_key?(index)
    cached = node_cache[:uninomial_with_garbage][index]
    if cached
      node_cache[:uninomial_with_garbage][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0, s0 = index, []
  r1 = _nt_uninomial_string
  s0 << r1
  if r1
    r2 = _nt_garbage
    s0 << r2
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(UninomialWithGarbage0)
    r0.extend(UninomialWithGarbage1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:uninomial_with_garbage][start_index] = r0

  r0
end

#rootObject



8
9
10
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 8

def root
  @root ||= :root
end