dimus-biodiversity 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -162,13 +162,13 @@ grammar ScientificNameClean
162
162
 
163
163
 
164
164
  rule multinomial_name
165
- a:genus space b:subgenus space c:species space_hard d:infraspecies_mult {
165
+ a:genus space b:subgenus space species_prefix? space c:species space_hard d:infraspecies_mult {
166
166
  def value
167
167
  a.value + " " + b.value + " " + c.value + " " + d.value
168
168
  end
169
169
 
170
170
  def canonical
171
- a.canonical + " " + c.canonical + " " + d.canonical
171
+ a.canonical + " " + b.canonical + " " + c.canonical + " " + d.canonical
172
172
  end
173
173
 
174
174
  def pos
@@ -180,7 +180,7 @@ grammar ScientificNameClean
180
180
  end
181
181
  }
182
182
  /
183
- a:genus space b:subgenus space c:species {
183
+ a:genus space b:subgenus space species_prefix? space c:species {
184
184
  def value
185
185
  a.value + " " + b.value + " " + c.value
186
186
  end
@@ -198,7 +198,7 @@ grammar ScientificNameClean
198
198
  end
199
199
  }
200
200
  /
201
- a:genus space_hard b:species space_hard c:infraspecies_mult {
201
+ a:genus space species_prefix? space b:species space_hard c:infraspecies_mult {
202
202
  def value
203
203
  a.value + " " + b.value + " " + c.value
204
204
  end
@@ -216,7 +216,7 @@ grammar ScientificNameClean
216
216
  end
217
217
  }
218
218
  /
219
- a:genus space_hard b:species {
219
+ a:genus space species_prefix? space b:species {
220
220
  def value
221
221
  a.value + " " + b.value
222
222
  end
@@ -250,7 +250,6 @@ grammar ScientificNameClean
250
250
  end
251
251
 
252
252
  def details
253
- #{:infraspecies => a.details[:infraspceies] << b.details[:infraspecies]}
254
253
  a_array = a.details[:infraspecies].class == Array ? a.details[:infraspecies] : [a.details[:infraspecies]]
255
254
  b_array = b.details[:infraspecies].class == Array ? b.details[:infraspecies] : [b.details[:infraspecies]]
256
255
  a.details.merge({:infraspecies => a_array + b_array})
@@ -320,7 +319,7 @@ grammar ScientificNameClean
320
319
  end
321
320
 
322
321
  rule taxon_concept_rank
323
- "sec." {
322
+ ("sec."/"sensu.") {
324
323
  def value
325
324
  "sec."
326
325
  end
@@ -454,17 +453,21 @@ grammar ScientificNameClean
454
453
  end
455
454
 
456
455
  rule genus
457
- cap_latin_word {
456
+ a:cap_latin_word !(space_hard author_prefix_word space_hard author_word) {
457
+ def value
458
+ a.value
459
+ end
460
+
458
461
  def pos
459
- {interval.begin => ['genus', interval.end]}
462
+ {a.interval.begin => ['genus', a.interval.end]}
460
463
  end
461
464
 
462
465
  def canonical
463
- value
466
+ a.value
464
467
  end
465
468
 
466
469
  def details
467
- {:genus => {:epitheton => value}}
470
+ {:genus => {:epitheton => a.value}}
468
471
  end
469
472
  }
470
473
  end
@@ -508,7 +511,7 @@ grammar ScientificNameClean
508
511
  end
509
512
 
510
513
  rule authorship
511
- a:basionym_authorship_with_parenthesis space b:simple_authorship space c:ex_authorship {
514
+ a:basionym_authorship_with_parenthesis space b:simple_authorship ","? space c:ex_authorship {
512
515
  def value
513
516
  a.value + " " + b.value + " " + c.value
514
517
  end
@@ -540,7 +543,7 @@ grammar ScientificNameClean
540
543
  /
541
544
  basionym_authorship_with_parenthesis
542
545
  /
543
- a:simple_authorship space b:ex_authorship {
546
+ a:simple_authorship ","? space b:ex_authorship {
544
547
  def value
545
548
  a.value + " " + b.value
546
549
  end
@@ -578,7 +581,7 @@ grammar ScientificNameClean
578
581
  end
579
582
  }
580
583
  /
581
- left_paren space a:simple_authorship space b:ex_authorship space right_paren {
584
+ left_paren space a:simple_authorship ","? space b:ex_authorship space right_paren {
582
585
  def value
583
586
  "(" + a.value + " " + b.value + ")"
584
587
  end
@@ -645,6 +648,28 @@ grammar ScientificNameClean
645
648
 
646
649
 
647
650
  rule simple_authorship
651
+ a:authors_names space [,]? space b:year? [,]? space "non" space authors_names space [,]? space year {
652
+ def value
653
+ a.value + " " + b.value
654
+ end
655
+
656
+ def pos
657
+ a.pos.merge(b.pos)
658
+ end
659
+
660
+ def details
661
+ details_with_arg(:basionymAuthorTeam)
662
+ end
663
+
664
+ def details_with_arg(authorTeamType = 'basionymAuthorTeam')
665
+ { :authorship => text_value,
666
+ authorTeamType.to_sym => {
667
+ :authorTeam => a.text_value.strip
668
+ }.merge(a.details).merge(b.details)
669
+ }
670
+ end
671
+ }
672
+ /
648
673
  a:authors_names space [,]? space b:year {
649
674
  def value
650
675
  a.value + " " + b.value
@@ -790,7 +815,7 @@ grammar ScientificNameClean
790
815
  end
791
816
  }
792
817
  /
793
- ("bis"/"arg."/"et al.\{\?\}"/"et al.") {
818
+ ("arg."/"et al.\{\?\}"/"et al.") {
794
819
  def value
795
820
  text_value.strip
796
821
  end
@@ -837,7 +862,7 @@ grammar ScientificNameClean
837
862
  end
838
863
 
839
864
  rule author_prefix_word
840
- space ("da"/"der"/"den"/"de"/"du"/"la"/"ter"/"van"/"von") &space_hard {
865
+ space ("ab"/"bis"/"da"/"der"/"den"/"della"/"dela"/"de"/"di"/"du"/"la"/"ter"/"van"/"von") &space_hard {
841
866
  def value
842
867
  text_value
843
868
  end
@@ -924,14 +949,10 @@ grammar ScientificNameClean
924
949
  end
925
950
  }
926
951
  end
927
-
928
- #rule species_word
929
- ## (!"sensu" a:species_word_0) {
930
- # def value
931
- # a.value
932
- # end
933
- # }
934
- #end
952
+
953
+ rule species_prefix
954
+ ("aff."/"corrig."/"?") &space_hard
955
+ end
935
956
 
936
957
  rule species_word
937
958
  a:[0-9]+ "-"? b:latin_word {
@@ -944,7 +965,7 @@ grammar ScientificNameClean
944
965
  end
945
966
 
946
967
  rule latin_word
947
- a:[a-zëüäöïé] b:full_name_letters {
968
+ a:[a-zëüäöïéåóç] b:full_name_letters {
948
969
  def value
949
970
  a.text_value + b.value
950
971
  end
@@ -974,7 +995,7 @@ grammar ScientificNameClean
974
995
  end
975
996
 
976
997
  rule valid_name_letters
977
- [a-z\-ëüäöïé]+ {
998
+ [a-z\-ëüäöïéåóç]+ {
978
999
  def value
979
1000
  text_value
980
1001
  end
@@ -23,6 +23,223 @@ module ScientificNameDirty
23
23
  return r0
24
24
  end
25
25
 
26
+ module ScientificName50
27
+ def a
28
+ elements[0]
29
+ end
30
+
31
+ def garbage
32
+ elements[1]
33
+ end
34
+ end
35
+
36
+ module ScientificName51
37
+ def value
38
+ a.value
39
+ end
40
+
41
+ def canonical
42
+ a.canonical
43
+ end
44
+
45
+ def pos
46
+ a.pos
47
+ end
48
+
49
+ def details
50
+ a.details
51
+ end
52
+ end
53
+
54
+ def _nt_scientific_name_5
55
+ start_index = index
56
+ if node_cache[:scientific_name_5].has_key?(index)
57
+ cached = node_cache[:scientific_name_5][index]
58
+ @index = cached.interval.end if cached
59
+ return cached
60
+ end
61
+
62
+ i0 = index
63
+ i1, s1 = index, []
64
+ r2 = _nt_scientific_name_4
65
+ s1 << r2
66
+ if r2
67
+ r3 = _nt_garbage
68
+ s1 << r3
69
+ end
70
+ if s1.last
71
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
72
+ r1.extend(ScientificName50)
73
+ r1.extend(ScientificName51)
74
+ else
75
+ self.index = i1
76
+ r1 = nil
77
+ end
78
+ if r1
79
+ r0 = r1
80
+ else
81
+ r4 = super
82
+ if r4
83
+ r0 = r4
84
+ else
85
+ self.index = i0
86
+ r0 = nil
87
+ end
88
+ end
89
+
90
+ node_cache[:scientific_name_5][start_index] = r0
91
+
92
+ return r0
93
+ end
94
+
95
+ module Infraspecies0
96
+ def a
97
+ elements[0]
98
+ end
99
+
100
+ def space
101
+ elements[1]
102
+ end
103
+
104
+ def b
105
+ elements[2]
106
+ end
107
+ end
108
+
109
+ module Infraspecies1
110
+ def value
111
+ a.value + " " + b.value
112
+ end
113
+
114
+ def canonical
115
+ a.canonical
116
+ end
117
+
118
+ def pos
119
+ a.pos.merge(b.pos)
120
+ end
121
+
122
+ def details
123
+ {:infraspecies => a.details[:infraspecies].merge(b.details)}
124
+ end
125
+ end
126
+
127
+ module Infraspecies2
128
+ def a
129
+ elements[0]
130
+ end
131
+
132
+ def space
133
+ elements[1]
134
+ end
135
+
136
+ def epitheton_authorship_inconsistencies
137
+ elements[2]
138
+ end
139
+
140
+ def space
141
+ elements[3]
142
+ end
143
+
144
+ def b
145
+ elements[4]
146
+ end
147
+ end
148
+
149
+ module Infraspecies3
150
+ def value
151
+ a.value + " " + b.value
152
+ end
153
+
154
+ def canonical
155
+ a.canonical
156
+ end
157
+
158
+ def pos
159
+ a.pos.merge(b.pos)
160
+ end
161
+
162
+ def details
163
+ {:infraspecies => a.details[:infraspecies].merge(b.details)}
164
+ end
165
+ end
166
+
167
+ def _nt_infraspecies
168
+ start_index = index
169
+ if node_cache[:infraspecies].has_key?(index)
170
+ cached = node_cache[:infraspecies][index]
171
+ @index = cached.interval.end if cached
172
+ return cached
173
+ end
174
+
175
+ i0 = index
176
+ i1, s1 = index, []
177
+ r2 = _nt_infraspecies_epitheton
178
+ s1 << r2
179
+ if r2
180
+ r3 = _nt_space
181
+ s1 << r3
182
+ if r3
183
+ r4 = _nt_year
184
+ s1 << r4
185
+ end
186
+ end
187
+ if s1.last
188
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
189
+ r1.extend(Infraspecies0)
190
+ r1.extend(Infraspecies1)
191
+ else
192
+ self.index = i1
193
+ r1 = nil
194
+ end
195
+ if r1
196
+ r0 = r1
197
+ else
198
+ i5, s5 = index, []
199
+ r6 = _nt_infraspecies_epitheton
200
+ s5 << r6
201
+ if r6
202
+ r7 = _nt_space
203
+ s5 << r7
204
+ if r7
205
+ r8 = _nt_epitheton_authorship_inconsistencies
206
+ s5 << r8
207
+ if r8
208
+ r9 = _nt_space
209
+ s5 << r9
210
+ if r9
211
+ r10 = _nt_authorship
212
+ s5 << r10
213
+ end
214
+ end
215
+ end
216
+ end
217
+ if s5.last
218
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
219
+ r5.extend(Infraspecies2)
220
+ r5.extend(Infraspecies3)
221
+ else
222
+ self.index = i5
223
+ r5 = nil
224
+ end
225
+ if r5
226
+ r0 = r5
227
+ else
228
+ r11 = super
229
+ if r11
230
+ r0 = r11
231
+ else
232
+ self.index = i0
233
+ r0 = nil
234
+ end
235
+ end
236
+ end
237
+
238
+ node_cache[:infraspecies][start_index] = r0
239
+
240
+ return r0
241
+ end
242
+
26
243
  module Species0
27
244
  def a
28
245
  elements[0]
@@ -335,20 +552,25 @@ module ScientificNameDirty
335
552
  if r5
336
553
  r0 = r5
337
554
  else
338
- r9 = _nt_approximate_year
555
+ r9 = _nt_year_number_with_punctuation
339
556
  if r9
340
557
  r0 = r9
341
558
  else
342
- r10 = _nt_double_year
559
+ r10 = _nt_approximate_year
343
560
  if r10
344
561
  r0 = r10
345
562
  else
346
- r11 = super
563
+ r11 = _nt_double_year
347
564
  if r11
348
565
  r0 = r11
349
566
  else
350
- self.index = i0
351
- r0 = nil
567
+ r12 = super
568
+ if r12
569
+ r0 = r12
570
+ else
571
+ self.index = i0
572
+ r0 = nil
573
+ end
352
574
  end
353
575
  end
354
576
  end
@@ -563,6 +785,62 @@ module ScientificNameDirty
563
785
  return r0
564
786
  end
565
787
 
788
+ module YearNumberWithPunctuation0
789
+ def a
790
+ elements[0]
791
+ end
792
+
793
+ end
794
+
795
+ module YearNumberWithPunctuation1
796
+ def value
797
+ a.text_value
798
+ end
799
+
800
+ def pos
801
+ {interval.begin => ['year', interval.end]}
802
+ end
803
+
804
+ def details
805
+ {:year => value}
806
+ end
807
+ end
808
+
809
+ def _nt_year_number_with_punctuation
810
+ start_index = index
811
+ if node_cache[:year_number_with_punctuation].has_key?(index)
812
+ cached = node_cache[:year_number_with_punctuation][index]
813
+ @index = cached.interval.end if cached
814
+ return cached
815
+ end
816
+
817
+ i0, s0 = index, []
818
+ r1 = _nt_year_number
819
+ s0 << r1
820
+ if r1
821
+ if input.index(".", index) == index
822
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
823
+ @index += 1
824
+ else
825
+ terminal_parse_failure(".")
826
+ r2 = nil
827
+ end
828
+ s0 << r2
829
+ end
830
+ if s0.last
831
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
832
+ r0.extend(YearNumberWithPunctuation0)
833
+ r0.extend(YearNumberWithPunctuation1)
834
+ else
835
+ self.index = i0
836
+ r0 = nil
837
+ end
838
+
839
+ node_cache[:year_number_with_punctuation][start_index] = r0
840
+
841
+ return r0
842
+ end
843
+
566
844
  module PageNumber0
567
845
  def space
568
846
  elements[1]
@@ -633,6 +911,144 @@ module ScientificNameDirty
633
911
  return r0
634
912
  end
635
913
 
914
+ def _nt_epitheton_authorship_inconsistencies
915
+ start_index = index
916
+ if node_cache[:epitheton_authorship_inconsistencies].has_key?(index)
917
+ cached = node_cache[:epitheton_authorship_inconsistencies][index]
918
+ @index = cached.interval.end if cached
919
+ return cached
920
+ end
921
+
922
+ if input.index("corrig.", index) == index
923
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 7))
924
+ @index += 7
925
+ else
926
+ terminal_parse_failure("corrig.")
927
+ r0 = nil
928
+ end
929
+
930
+ node_cache[:epitheton_authorship_inconsistencies][start_index] = r0
931
+
932
+ return r0
933
+ end
934
+
935
+ module Garbage0
936
+ def space
937
+ elements[0]
938
+ end
939
+
940
+ def space
941
+ elements[2]
942
+ end
943
+
944
+ end
945
+
946
+ module Garbage1
947
+ def space_hard
948
+ elements[0]
949
+ end
950
+
951
+ end
952
+
953
+ def _nt_garbage
954
+ start_index = index
955
+ if node_cache[:garbage].has_key?(index)
956
+ cached = node_cache[:garbage][index]
957
+ @index = cached.interval.end if cached
958
+ return cached
959
+ end
960
+
961
+ i0 = index
962
+ i1, s1 = index, []
963
+ r2 = _nt_space
964
+ s1 << r2
965
+ if r2
966
+ if input.index(Regexp.new('["\',.]'), index) == index
967
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
968
+ @index += 1
969
+ else
970
+ r3 = nil
971
+ end
972
+ s1 << r3
973
+ if r3
974
+ r4 = _nt_space
975
+ s1 << r4
976
+ if r4
977
+ s5, i5 = [], index
978
+ loop do
979
+ if input.index(Regexp.new('[^щ]'), index) == index
980
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
981
+ @index += 1
982
+ else
983
+ r6 = nil
984
+ end
985
+ if r6
986
+ s5 << r6
987
+ else
988
+ break
989
+ end
990
+ end
991
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
992
+ s1 << r5
993
+ end
994
+ end
995
+ end
996
+ if s1.last
997
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
998
+ r1.extend(Garbage0)
999
+ else
1000
+ self.index = i1
1001
+ r1 = nil
1002
+ end
1003
+ if r1
1004
+ r0 = r1
1005
+ else
1006
+ i7, s7 = index, []
1007
+ r8 = _nt_space_hard
1008
+ s7 << r8
1009
+ if r8
1010
+ s9, i9 = [], index
1011
+ loop do
1012
+ if input.index(Regexp.new('[^ш]'), index) == index
1013
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
1014
+ @index += 1
1015
+ else
1016
+ r10 = nil
1017
+ end
1018
+ if r10
1019
+ s9 << r10
1020
+ else
1021
+ break
1022
+ end
1023
+ end
1024
+ if s9.empty?
1025
+ self.index = i9
1026
+ r9 = nil
1027
+ else
1028
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
1029
+ end
1030
+ s7 << r9
1031
+ end
1032
+ if s7.last
1033
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1034
+ r7.extend(Garbage1)
1035
+ else
1036
+ self.index = i7
1037
+ r7 = nil
1038
+ end
1039
+ if r7
1040
+ r0 = r7
1041
+ else
1042
+ self.index = i0
1043
+ r0 = nil
1044
+ end
1045
+ end
1046
+
1047
+ node_cache[:garbage][start_index] = r0
1048
+
1049
+ return r0
1050
+ end
1051
+
636
1052
  end
637
1053
 
638
1054
  class ScientificNameDirtyParser < Treetop::Runtime::CompiledParser