Module: ScientificNameCanonical

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

Defined Under Namespace

Modules: Garbage0, Garbage1, 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_epitheton_authorship_inconsistencies, #_nt_infraspecies, #_nt_left_paren, #_nt_page_number, #_nt_right_paren, #_nt_scientific_name_5, #_nt_species, #_nt_year, #_nt_year_number_with_punctuation

Methods included from ScientificNameClean

#_nt_author_name, #_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_digraph, #_nt_ex_authorship, #_nt_ex_sep, #_nt_full_name_letters, #_nt_genus, #_nt_hybrid_character, #_nt_infraspecies, #_nt_infraspecies_epitheton, #_nt_infraspecies_mult, #_nt_latin_word, #_nt_left_paren, #_nt_multinomial_name, #_nt_multiplication_sign, #_nt_rank, #_nt_rank_forma, #_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_epitheton, #_nt_species_prefix, #_nt_species_word, #_nt_species_word_hybrid, #_nt_status_part, #_nt_status_word, #_nt_subgenus, #_nt_taxon_concept_rank, #_nt_uninomial_epitheton, #_nt_uninomial_name, #_nt_unknown_auth, #_nt_valid_name_letters, #_nt_year, #_nt_year_number, #_nt_year_number_with_character

Instance Method Details

#_nt_garbageObject



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
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
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 359

def _nt_garbage
  start_index = index
  if node_cache[:garbage].has_key?(index)
    cached = node_cache[:garbage][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0 = index
  i1, s1 = index, []
  r2 = _nt_space
  s1 << r2
  if r2
    if has_terminal?('\G["\',.]', true, index)
      r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      r3 = nil
    end
    s1 << r3
    if r3
      r4 = _nt_space
      s1 << r4
      if r4
        s5, i5 = [], index
        loop do
          if has_terminal?('\G[^щ]', true, index)
            r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            r6 = nil
          end
          if r6
            s5 << r6
          else
            break
          end
        end
        r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
        s1 << r5
      end
    end
  end
  if s1.last
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    r1.extend(Garbage0)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r0 = r1
  else
    i7, s7 = index, []
    r8 = _nt_space_hard
    s7 << r8
    if r8
      s9, i9 = [], index
      loop do
        if has_terminal?('\G[^ш]', true, index)
          r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          r10 = nil
        end
        if r10
          s9 << r10
        else
          break
        end
      end
      if s9.empty?
        @index = i9
        r9 = nil
      else
        r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
      end
      s7 << r9
    end
    if s7.last
      r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
      r7.extend(Garbage1)
    else
      @index = i7
      r7 = nil
    end
    if r7
      r0 = r7
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:garbage][start_index] = r0

  r0
end

#_nt_multinomial_with_garbageObject



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
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
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 178

def _nt_multinomial_with_garbage
  start_index = index
  if node_cache[:multinomial_with_garbage].has_key?(index)
    cached = node_cache[:multinomial_with_garbage][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0 = index
  i1, s1 = index, []
  r2 = _nt_genus
  s1 << r2
  if r2
    r3 = _nt_space
    s1 << r3
    if r3
      r4 = _nt_subgenus
      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
    r0 = r1
  else
    i8, s8 = index, []
    r9 = _nt_genus
    s8 << r9
    if r9
      r10 = _nt_space
      s8 << r10
      if r10
        r11 = _nt_subgenus
        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
      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
        r0 = r13
      else
        @index = i0
        r0 = nil
      end
    end
  end

  node_cache[:multinomial_with_garbage][start_index] = r0

  r0
end

#_nt_rootObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 33

def _nt_root
  start_index = index
  if node_cache[:root].has_key?(index)
    cached = node_cache[:root][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0 = index
  r1 = _nt_multinomial_with_garbage
  r1.extend(Root0)
  if r1
    r0 = r1
  else
    r2 = _nt_uninomial_with_garbage
    r2.extend(Root1)
    if r2
      r0 = r2
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:root][start_index] = r0

  r0
end

#_nt_uninomial_with_garbageObject



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 312

def _nt_uninomial_with_garbage
  start_index = index
  if node_cache[:uninomial_with_garbage].has_key?(index)
    cached = node_cache[:uninomial_with_garbage][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0, s0 = index, []
  r1 = _nt_uninomial_epitheton
  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



5
6
7
# File 'lib/biodiversity/parser/scientific_name_canonical.rb', line 5

def root
  @root || :root
end