biodiversity19 0.5.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,504 @@
1
+ # encoding: UTF-8
2
+ dir = File.dirname("__FILE__")
3
+ require File.expand_path(dir + '../../spec/parser/spec_helper')
4
+
5
+
6
+ describe ScientificNameClean do
7
+ before(:all) do
8
+ set_parser(ScientificNameCleanParser.new)
9
+ end
10
+
11
+ it 'should parse uninomial' do
12
+ sn = 'Pseudocercospora'
13
+ parse(sn).should_not be_nil
14
+ value(sn).should == 'Pseudocercospora'
15
+ canonical(sn).should == 'Pseudocercospora'
16
+ details(sn).should == [{:uninomial=>{:string=>"Pseudocercospora"}}]
17
+ pos(sn).should == {0=>["uninomial", 16]}
18
+ end
19
+
20
+ it 'should parse uninomial with author and year' do
21
+ sn = 'Pseudocercospora Speg.'
22
+ parse(sn).should_not be_nil
23
+ details(sn).should == [{:uninomial=>{:string=>"Pseudocercospora", :authorship=>"Speg.", :basionymAuthorTeam=>{:authorTeam=>"Speg.", :author=>["Speg."]}}}]
24
+ pos(sn).should == {0=>["uninomial", 16], 17=>["author_word", 22]}
25
+ sn = 'Pseudocercospora Spegazzini, 1910'
26
+ parse(sn).should_not be_nil
27
+ value(sn).should == 'Pseudocercospora Spegazzini 1910'
28
+ details(sn).should == [{:uninomial=>{:string=>"Pseudocercospora", :authorship=>"Spegazzini, 1910", :basionymAuthorTeam=>{:authorTeam=>"Spegazzini", :author=>["Spegazzini"], :year=>"1910"}}}]
29
+ pos(sn).should == {0=>["uninomial", 16], 17=>["author_word", 27], 29=>["year", 33]}
30
+ end
31
+
32
+ it 'should parse names with a valid 2 letter genus' do
33
+ ["Ca Dyar 1914",
34
+ "Ea Distant 1911",
35
+ "Ge Nicéville 1895",
36
+ "Ia Thomas 1902",
37
+ "Io Lea 1831",
38
+ "Io Blanchard 1852",
39
+ "Ix Bergroth 1916",
40
+ "Lo Seale 1906",
41
+ "Oa Girault 1929",
42
+ "Ra Whitley 1931",
43
+ "Ty Bory de St. Vincent 1827",
44
+ "Ua Girault 1929",
45
+ "Aa Baker 1940",
46
+ "Ja Uéno 1955",
47
+ "Zu Walters & Fitch 1960",
48
+ "La Bleszynski 1966",
49
+ "Qu Durkoop",
50
+ "As Slipinski 1982",
51
+ "Ba Solem 1983"].each do |name|
52
+ parse(name).should_not be_nil
53
+ end
54
+ canonical('Quoyula').should == 'Quoyula'
55
+ end
56
+
57
+ it 'should parse canonical' do
58
+ sn = 'Pseudocercospora dendrobii'
59
+ parse(sn).should_not be_nil
60
+ value(sn).should == 'Pseudocercospora dendrobii'
61
+ canonical(sn).should == 'Pseudocercospora dendrobii'
62
+ details(sn).should == [{:genus=>{:string=>"Pseudocercospora"}, :species=>{:string=>"dendrobii"}}]
63
+ pos(sn).should == {0=>["genus", 16], 21=>["species", 30]}
64
+ end
65
+
66
+
67
+ it 'should parse species name with author and year' do
68
+ sn = "Platypus bicaudatulus Schedl 1935"
69
+ parse(sn).should_not be_nil
70
+ value(sn).should == "Platypus bicaudatulus Schedl 1935"
71
+ sn = "Platypus bicaudatulus Schedl, 1935h"
72
+ parse(sn).should_not be_nil
73
+ value(sn).should == "Platypus bicaudatulus Schedl 1935"
74
+ details(sn).should == [{:genus=>{:string=>"Platypus"}, :species=>{:string=>"bicaudatulus", :authorship=>"Schedl, 1935h", :basionymAuthorTeam=>{:authorTeam=>"Schedl", :author=>["Schedl"], :year=>"1935"}}}]
75
+ pos(sn).should == {0=>["genus", 8], 9=>["species", 21], 22=>["author_word", 28], 30=>["year", 35]}
76
+ parse("Platypus bicaudatulus Schedl, 1935B").should_not be_nil
77
+ sn = "Platypus bicaudatulus Schedl (1935h)"
78
+ parse(sn).should_not be_nil
79
+ details(sn).should == [{:genus=>{:string=>"Platypus"}, :species=>{:string=>"bicaudatulus", :authorship=>"Schedl (1935h)", :basionymAuthorTeam=>{:authorTeam=>"Schedl", :author=>["Schedl"], :year=>"1935"}}}]
80
+ parse("Platypus bicaudatulus Schedl 1935").should_not be_nil
81
+ end
82
+
83
+ it 'should parse genus with "?"' do
84
+ sn = "Ferganoconcha? oblonga"
85
+ parse(sn).should_not be_nil
86
+ value(sn).should == "Ferganoconcha oblonga"
87
+ details(sn).should == [{:genus=>{:string=>"Ferganoconcha"}, :species=>{:string=>"oblonga"}}]
88
+ pos(sn).should == {0=>["genus", 14], 15=>["species", 22]}
89
+ end
90
+
91
+ it 'should parse æ in the name' do
92
+ names = [
93
+ ["Læptura laetifica Dow, 1913", "Laeptura laetifica Dow 1913"],
94
+ ["Leptura lætifica Dow, 1913", "Leptura laetifica Dow 1913"],
95
+ ["Leptura leætifica Dow, 1913", "Leptura leaetifica Dow 1913"],
96
+ ["Leæptura laetifica Dow, 1913", "Leaeptura laetifica Dow 1913"],
97
+ ["Leœptura laetifica Dow, 1913", "Leoeptura laetifica Dow 1913"],
98
+ ['Ærenea cognata Lacordaire, 1872', 'Aerenea cognata Lacordaire 1872'],
99
+ ['Œdicnemus capensis', 'Oedicnemus capensis'],
100
+ ['Œnanthe œnanthe','Oenanthe oenanthe']
101
+ ]
102
+ names.each do |name_pair|
103
+ parse(name_pair[0]).should_not be_nil
104
+ value(name_pair[0]).should == name_pair[1]
105
+ end
106
+ end
107
+
108
+ it 'should parse names with "common" utf-8 charactes' do
109
+ names = ["Rühlella","Sténométope laevissimus Bibron 1855"].each do |name|
110
+ parse(name).should_not be_nil
111
+ end
112
+ sn = "Trematosphaeria phaeospora (E. Müll.) L. Holm 1957"
113
+ parse(sn).should_not be_nil
114
+ value(sn).should == "Trematosphaeria phaeospora (E. Müll.) L. Holm 1957"
115
+ canonical(sn).should == "Trematosphaeria phaeospora"
116
+ details(sn).should == [{:genus=>{:string=>"Trematosphaeria"}, :species=>{:string=>"phaeospora", :authorship=>"(E. Müll.) L. Holm 1957", :combinationAuthorTeam=>{:authorTeam=>"L. Holm", :author=>["L. Holm"], :year=>"1957"}, :basionymAuthorTeam=>{:authorTeam=>"E. Müll.", :author=>["E. Müll."]}}}]
117
+ pos(sn).should == {0=>["genus", 15], 16=>["species", 26], 28=>["author_word", 30], 31=>["author_word", 36], 46=>["author_word", 48], 61=>["author_word", 65], 66=>["year", 70]}
118
+
119
+ end
120
+
121
+ it 'should parse infragenus (ICZN code)' do
122
+ sn = "Hegeter (Hegeter) intercedens Lindberg H 1950"
123
+ parse(sn).should_not be_nil
124
+ value(sn).should == "Hegeter (Hegeter) intercedens Lindberg H 1950"
125
+ canonical(sn).should == "Hegeter intercedens"
126
+ details(sn).should == [{:genus=>{:string=>"Hegeter"}, :infragenus=>{:string=>"Hegeter"}, :species=>{:string=>"intercedens", :authorship=>"Lindberg H 1950", :basionymAuthorTeam=>{:authorTeam=>"Lindberg H", :author=>["Lindberg H"], :year=>"1950"}}}]
127
+ pos(sn).should == {0=>["genus", 7], 9=>["infragenus", 16], 18=>["species", 29], 30=>["author_word", 38], 39=>["author_word", 40], 41=>["year", 45]}
128
+ end
129
+
130
+ it 'should parse several authors without a year' do
131
+ sn = "Pseudocercospora dendrobii U. Braun & Crous"
132
+ parse(sn).should_not be_nil
133
+ value(sn).should == "Pseudocercospora dendrobii U. Braun et Crous"
134
+ canonical(sn).should == "Pseudocercospora dendrobii"
135
+ details(sn).should == [{:genus=>{:string=>"Pseudocercospora"}, :species=>{:string=>"dendrobii", :authorship=>"U. Braun & Crous", :basionymAuthorTeam=>{:authorTeam=>"U. Braun & Crous", :author=>["U. Braun", "Crous"]}}}]
136
+ pos(sn).should == {0=>["genus", 16], 17=>["species", 26], 27=>["author_word", 29], 30=>["author_word", 35], 38=>["author_word", 43]}
137
+ sn = "Pseudocercospora dendrobii U. Braun and Crous"
138
+ parse(sn).should_not be_nil
139
+ value(sn).should == "Pseudocercospora dendrobii U. Braun et Crous"
140
+ pos(sn).should == {0=>["genus", 16], 17=>["species", 26], 27=>["author_word", 29], 30=>["author_word", 35], 40=>["author_word", 45]}
141
+ sn = "Pseudocercospora dendrobii U. Braun et Crous"
142
+ parse(sn).should_not be_nil
143
+ value(sn).should == "Pseudocercospora dendrobii U. Braun et Crous"
144
+ sn = "Arthopyrenia hyalospora(Nyl.)R.C. Harris"
145
+ parse(sn).should_not be_nil
146
+ value(sn).should == "Arthopyrenia hyalospora (Nyl.) R.C. Harris"
147
+ canonical(sn).should == "Arthopyrenia hyalospora"
148
+ details(sn).should == [{:genus=>{:string=>"Arthopyrenia"}, :species=>{:string=>"hyalospora", :authorship=>"(Nyl.)R.C. Harris", :combinationAuthorTeam=>{:authorTeam=>"R.C. Harris", :author=>["R.C. Harris"]}, :basionymAuthorTeam=>{:authorTeam=>"Nyl.", :author=>["Nyl."]}}}]
149
+ end
150
+
151
+
152
+
153
+ it 'should parse several authors with a year' do
154
+ sn = "Pseudocercospora dendrobii U. Braun & Crous 2003"
155
+ parse(sn).should_not be_nil
156
+ value(sn).should == "Pseudocercospora dendrobii U. Braun et Crous 2003"
157
+ canonical(sn).should == "Pseudocercospora dendrobii"
158
+ details(sn).should == [{:genus=>{:string=>"Pseudocercospora"}, :species=>{:string=>"dendrobii", :authorship=>"U. Braun & Crous 2003", :basionymAuthorTeam=>{:authorTeam=>"U. Braun & Crous", :author=>["U. Braun", "Crous"], :year=>"2003"}}}]
159
+ pos(sn).should == {0=>["genus", 16], 17=>["species", 26], 27=>["author_word", 29], 30=>["author_word", 35], 38=>["author_word", 43], 44=>["year", 48]}
160
+ sn = "Pseudocercospora dendrobii Crous, 2003"
161
+ parse(sn).should_not be_nil
162
+ end
163
+
164
+ it 'should parse basionym authors in parenthesis' do
165
+ sn = "Zophosis persis (Chatanay, 1914)"
166
+ parse(sn).should_not be_nil
167
+ details(sn).should == [{:genus=>{:string=>"Zophosis"}, :species=>{:string=>"persis", :authorship=>"(Chatanay, 1914)", :basionymAuthorTeam=>{:authorTeam=>"Chatanay", :author=>["Chatanay"], :year=>"1914"}}}]
168
+ sn = "Zophosis persis (Chatanay 1914)"
169
+ parse(sn).should_not be_nil
170
+ details(sn).should == [{:genus=>{:string=>"Zophosis"}, :species=>{:string=>"persis", :authorship=>"(Chatanay 1914)", :basionymAuthorTeam=>{:authorTeam=>"Chatanay", :author=>["Chatanay"], :year=>"1914"}}}]
171
+ sn = "Zophosis persis (Chatanay), 1914"
172
+ parse(sn).should_not be_nil
173
+ value(sn).should == "Zophosis persis (Chatanay 1914)"
174
+ details(sn).should == [{:genus=>{:string=>"Zophosis"}, :species=>{:string=>"persis", :authorship=>"(Chatanay), 1914", :basionymAuthorTeam=>{:author_team=>"(Chatanay), 1914", :author=>["Chatanay"], :year=>"1914"}}}]
175
+ pos(sn).should == {0=>["genus", 8], 9=>["species", 15], 17=>["author_word", 25], 28=>["year", 32]}
176
+ parse("Zophosis persis (Chatanay) 1914").should_not be_nil
177
+ #parse("Zophosis persis Chatanay (1914)").should_not be_nil
178
+ end
179
+
180
+ it 'should parse scientific name' do
181
+ sn = "Pseudocercospora dendrobii(H.C. Burnett)U. Braun & Crous 2003"
182
+ parse(sn).should_not be_nil
183
+ value(sn).should == "Pseudocercospora dendrobii (H.C. Burnett) U. Braun et Crous 2003"
184
+ canonical(sn).should == "Pseudocercospora dendrobii"
185
+ details(sn).should == [{:genus=>{:string=>"Pseudocercospora"}, :species=>{:string=>"dendrobii", :authorship=>"(H.C. Burnett)U. Braun & Crous 2003", :combinationAuthorTeam=>{:authorTeam=>"U. Braun & Crous", :author=>["U. Braun", "Crous"], :year=>"2003"}, :basionymAuthorTeam=>{:authorTeam=>"H.C. Burnett", :author=>["H.C. Burnett"]}}}]
186
+ sn = "Pseudocercospora dendrobii(H.C. Burnett,1873)U. Braun & Crous 2003"
187
+ parse(sn).should_not be_nil
188
+ value(sn).should == "Pseudocercospora dendrobii (H.C. Burnett 1873) U. Braun et Crous 2003"
189
+ details(sn).should == [{:genus=>{:string=>"Pseudocercospora"}, :species=>{:string=>"dendrobii", :authorship=>"(H.C. Burnett,1873)U. Braun & Crous 2003", :combinationAuthorTeam=>{:authorTeam=>"U. Braun & Crous", :author=>["U. Braun", "Crous"], :year=>"2003"}, :basionymAuthorTeam=>{:authorTeam=>"H.C. Burnett", :author=>["H.C. Burnett"], :year=>"1873"}}}]
190
+ end
191
+
192
+ it 'should parse several authors with several years' do
193
+ sn = "Pseudocercospora dendrobii (H.C. Burnett 1883) U. Braun & Crous 2003"
194
+ parse(sn).should_not be_nil
195
+ value(sn).should == "Pseudocercospora dendrobii (H.C. Burnett 1883) U. Braun et Crous 2003"
196
+ canonical(sn).should == "Pseudocercospora dendrobii"
197
+ details(sn).should == [{:genus=>{:string=>"Pseudocercospora"}, :species=>{:string=>"dendrobii", :authorship=>"(H.C. Burnett 1883) U. Braun & Crous 2003", :combinationAuthorTeam=>{:authorTeam=>"U. Braun & Crous", :author=>["U. Braun", "Crous"], :year=>"2003"}, :basionymAuthorTeam=>{:authorTeam=>"H.C. Burnett", :author=>["H.C. Burnett"], :year=>"1883"}}}]
198
+ pos(sn).should == {0=>["genus", 16], 17=>["species", 26], 28=>["author_word", 32], 33=>["author_word", 40], 41=>["year", 45], 47=>["author_word", 49], 50=>["author_word", 55], 58=>["author_word", 63], 64=>["year", 68]}
199
+ end
200
+
201
+ it "should parse name with subspecies without rank Zoological Code" do
202
+ sn = "Hydnellum scrobiculatum zonatum (Banker) D. Hall & D.E. Stuntz 1972"
203
+ parse(sn).should_not be_nil
204
+ value(sn).should == "Hydnellum scrobiculatum zonatum (Banker) D. Hall et D.E. Stuntz 1972"
205
+ canonical(sn).should == "Hydnellum scrobiculatum zonatum"
206
+ details(sn).should == [{:genus=>{:string=>"Hydnellum"}, :species=>{:string=>"scrobiculatum"}, :infraspecies=>[{:string=>"zonatum", :rank=>"n/a", :authorship=>"(Banker) D. Hall & D.E. Stuntz 1972", :combinationAuthorTeam=>{:authorTeam=>"D. Hall & D.E. Stuntz", :author=>["D. Hall", "D.E. Stuntz"], :year=>"1972"}, :basionymAuthorTeam=>{:authorTeam=>"Banker", :author=>["Banker"]}}]}]
207
+ pos(sn).should == {0=>["genus", 9], 10=>["species", 23], 24=>["infraspecies", 31], 33=>["author_word", 39], 41=>["author_word", 43], 44=>["author_word", 48], 51=>["author_word", 55], 56=>["author_word", 62], 63=>["year", 67]}
208
+ sn = "Begonia pingbienensis angustior"
209
+ parse(sn).should_not be_nil
210
+ details(sn).should == [{:genus=>{:string=>"Begonia"}, :species=>{:string=>"pingbienensis"}, :infraspecies=>[{:string=>"angustior", :rank=>"n/a"}]}]
211
+ pos(sn).should == {0=>["genus", 7], 8=>["species", 21], 22=>["infraspecies", 31]}
212
+ end
213
+
214
+ it 'should parse infraspecies with rank' do
215
+ sn = "Aus bus Linn. var. bus"
216
+ parse(sn).should_not be_nil
217
+ details(sn).should == [{:genus=>{:string=>"Aus"}, :species=>{:string=>"bus", :authorship=>"Linn.", :basionymAuthorTeam=>{:authorTeam=>"Linn.", :author=>["Linn."]}}, :infraspecies=>[{:string=>"bus", :rank=>"var."}]}]
218
+ sn = "Agalinis purpurea (L.) Briton var. borealis (Berg.) Peterson 1987"
219
+ parse(sn).should_not be_nil
220
+ details(sn).should == [{:genus=>{:string=>"Agalinis"}, :species=>{:string=>"purpurea", :authorship=>"(L.) Briton", :combinationAuthorTeam=>{:authorTeam=>"Briton", :author=>["Briton"]}, :basionymAuthorTeam=>{:authorTeam=>"L.", :author=>["L."]}}, :infraspecies=>[{:string=>"borealis", :rank=>"var.", :authorship=>"(Berg.) Peterson 1987", :combinationAuthorTeam=>{:authorTeam=>"Peterson", :author=>["Peterson"], :year=>"1987"}, :basionymAuthorTeam=>{:authorTeam=>"Berg.", :author=>["Berg."]}}]}]
221
+ pos(sn).should == {0=>["genus", 8], 9=>["species", 17], 19=>["author_word", 21], 23=>["author_word", 29], 35=>["infraspecies", 43], 45=>["author_word", 50], 52=>["author_word", 60], 61=>["year", 65]}
222
+ sn = "Phaeographis inusta var. macularis(Leight.) A.L. Sm. 1861"
223
+ parse(sn).should_not be_nil
224
+ value(sn).should == "Phaeographis inusta var. macularis (Leight.) A.L. Sm. 1861"
225
+ canonical(sn).should == "Phaeographis inusta macularis"
226
+ pos(sn).should == {0=>["genus", 12], 13=>["species", 19], 25=>["infraspecies", 34], 35=>["author_word", 42], 44=>["author_word", 48], 49=>["author_word", 52], 53=>["year", 57]}
227
+ end
228
+
229
+ it 'should parse unknown original authors (auct.)/(hort.)/(?)' do
230
+ sn = "Tragacantha leporina (?) Kuntze"
231
+ parse(sn).should_not be_nil
232
+ value(sn).should == "Tragacantha leporina (?) Kuntze"
233
+ details(sn).should == [{:genus=>{:string=>"Tragacantha"}, :species=>{:string=>"leporina", :authorship=>"(?) Kuntze", :combinationAuthorTeam=>{:authorTeam=>"Kuntze", :author=>["Kuntze"]}, :basionymAuthorTeam=>{:authorTeam=>"(?)", :author=>["?"]}}}]
234
+ sn = "Lachenalia tricolor var. nelsonii (auct.) Baker"
235
+ parse(sn).should_not be_nil
236
+ value(sn).should == "Lachenalia tricolor var. nelsonii (auct.) Baker"
237
+ details(sn).should == [{:genus=>{:string=>"Lachenalia"}, :species=>{:string=>"tricolor"}, :infraspecies=>[{:string=>"nelsonii", :rank=>"var.", :authorship=>"(auct.) Baker", :combinationAuthorTeam=>{:authorTeam=>"Baker", :author=>["Baker"]}, :basionymAuthorTeam=>{:authorTeam=>"auct.", :author=>["unknown"]}}]}]
238
+ pos(sn).should == {0=>["genus", 10], 11=>["species", 19], 25=>["infraspecies", 33], 35=>["unknown_author", 40], 42=>["author_word", 47]}
239
+ end
240
+
241
+ it 'should parse unknown authors auct./anon./hort./ht.' do
242
+ sn = "Puya acris ht."
243
+ parse(sn).should_not be_nil
244
+ pos(sn).should == {0=>["genus", 4], 5=>["species", 10], 11=>["unknown_author", 14]}
245
+ end
246
+
247
+ it 'shuould parse real world examples' do
248
+ sn = "Stagonospora polyspora M.T. Lucas & Sousa da Câmara 1934"
249
+ parse(sn).should_not be_nil
250
+ value(sn).should == "Stagonospora polyspora M.T. Lucas et Sousa da Câmara 1934"
251
+ details(sn).should == [{:genus=>{:string=>"Stagonospora"}, :species=>{:string=>"polyspora", :authorship=>"M.T. Lucas & Sousa da Câmara 1934", :basionymAuthorTeam=>{:authorTeam=>"M.T. Lucas & Sousa da Câmara", :author=>["M.T. Lucas", "Sousa da Câmara"], :year=>"1934"}}}]
252
+ pos(sn).should == {0=>["genus", 12], 13=>["species", 22], 23=>["author_word", 27], 28=>["author_word", 33], 36=>["author_word", 41], 42=>["author_word", 44], 45=>["author_word", 51], 52=>["year", 56]}
253
+ parse("Cladoniicola staurospora Diederich, van den Boom & Aptroot 2001").should_not be_nil
254
+ sn = "Yarrowia lipolytica var. lipolytica (Wick., Kurtzman & E.A. Herrm.) Van der Walt & Arx 1981"
255
+ parse(sn).should_not be_nil
256
+ value(sn).should == "Yarrowia lipolytica var. lipolytica (Wick., Kurtzman et E.A. Herrm.) Van der Walt et Arx 1981"
257
+ pos(sn).should == {0=>["genus", 8], 9=>["species", 19], 25=>["infraspecies", 35], 37=>["author_word", 42], 44=>["author_word", 52], 55=>["author_word", 59], 60=>["author_word", 66], 68=>["author_word", 71], 72=>["author_word", 75], 76=>["author_word", 80], 83=>["author_word", 86], 87=>["year", 91]}
258
+ parse("Physalospora rubiginosa (Fr.) anon.").should_not be_nil
259
+ parse("Pleurotus ëous (Berk.) Sacc. 1887").should_not be_nil
260
+ parse("Lecanora wetmorei Śliwa 2004").should_not be_nil
261
+ # valid
262
+ # infraspecific
263
+ parse("Calicium furfuraceum * furfuraceum (L.) Pers. 1797").should_not be_nil
264
+ parse("Exobasidium vaccinii ** andromedae (P. Karst.) P. Karst. 1882").should_not be_nil
265
+ parse("Urceolaria scruposa **** clausa Flot. 1849").should_not be_nil
266
+ parse("Cortinarius angulatus B gracilescens Fr. 1838").should_not be_nil
267
+ parse("Cyathicula scelobelonium").should_not be_nil
268
+ # single quote that did not show
269
+ # parse("Phytophthora hedraiandra De Cock & Man in ?t Veld 2004"
270
+ # Phthora vastatrix d?Hérelle 1909
271
+ # author is exception
272
+ sn = "Tuber liui A S. Xu 1999"
273
+ parse(sn).should_not be_nil
274
+ details(sn).should == [{:genus=>{:string=>"Tuber"}, :species=>{:string=>"liui", :authorship=>"A S. Xu 1999", :basionymAuthorTeam=>{:authorTeam=>"A S. Xu", :author=>["A S. Xu"], :year=>"1999"}}}]
275
+ parse('Xylaria potentillae A S. Xu').should_not be_nil
276
+ parse("Agaricus squamula Berk. & M.A. Curtis 1860").should_not be_nil
277
+ parse("Peltula coriacea Büdel, Henssen & Wessels 1986").should_not be_nil
278
+ #had to add no dot rule for trinomials without a rank to make it to work
279
+ sn = "Saccharomyces drosophilae anon."
280
+ parse(sn).should_not be_nil
281
+ details(sn).should == [{:genus=>{:string=>"Saccharomyces"}, :species=>{:string=>"drosophilae", :authorship=>"anon.", :basionymAuthorTeam=>{:authorTeam=>"anon.", :author=>["unknown"]}}}]
282
+ pos(sn).should == {0=>["genus", 13], 14=>["species", 25], 26=>["unknown_author", 31]}
283
+ sn = "Abacetus laevicollis de Chaudoir, 1869"
284
+ parse(sn).should_not be_nil
285
+ canonical(sn).should == 'Abacetus laevicollis'
286
+ sn = "Gastrosericus eremorum van Beaumont 1955"
287
+ canonical(sn).should == 'Gastrosericus eremorum'
288
+ sn = "Gastrosericus eremorum von Beaumont 1955"
289
+ canonical(sn).should == 'Gastrosericus eremorum'
290
+ sn = "Cypraeovula (Luponia) amphithales perdentata"
291
+ canonical(sn).should == 'Cypraeovula Luponia amphithales perdentata'
292
+ details(sn).should == [{:genus=>{:string=>"Cypraeovula"}, :infragenus=>{:string=>"Luponia"}, :species=>{:string=>"amphithales"}, :infraspecies=>[{:string=>"perdentata", :rank=>"n/a"}]}]
293
+ sn = "Polyrhachis orsyllus nat musculus Forel 1901"
294
+ canonical(sn).should == "Polyrhachis orsyllus musculus"
295
+ sn = 'Latrodectus 13-guttatus Thorell, 1875'
296
+ canonical(sn).should == 'Latrodectus 13-guttatus'
297
+ value(sn).should == 'Latrodectus 13-guttatus Thorell 1875'
298
+ sn = 'Latrodectus 3guttatus Thorell, 1875'
299
+ canonical(sn).should == 'Latrodectus 3-guttatus'
300
+ value(sn).should == 'Latrodectus 3-guttatus Thorell 1875'
301
+ end
302
+
303
+ it "should parse name with morph." do
304
+ sn = "Callideriphus flavicollis morph. reductus Fuchs 1961"
305
+ parse(sn).should_not be_nil
306
+ value(sn).should == "Callideriphus flavicollis morph. reductus Fuchs 1961"
307
+ canonical(sn).should == "Callideriphus flavicollis reductus"
308
+ details(sn).should == [{:genus=>{:string=>"Callideriphus"}, :species=>{:string=>"flavicollis"}, :infraspecies=>[{:string=>"reductus", :rank=>"morph.", :authorship=>"Fuchs 1961", :basionymAuthorTeam=>{:authorTeam=>"Fuchs", :author=>["Fuchs"], :year=>"1961"}}]}]
309
+ pos(sn).should == {0=>["genus", 13], 14=>["species", 25], 33=>["infraspecies", 41], 42=>["author_word", 47], 48=>["year", 52]}
310
+ end
311
+
312
+
313
+ it "should parse name with forma/fo./form./f." do
314
+ sn = "Caulerpa cupressoides forma nuda"
315
+ parse(sn).should_not be_nil
316
+ value(sn).should == "Caulerpa cupressoides f. nuda"
317
+ canonical(sn).should == "Caulerpa cupressoides nuda"
318
+ details(sn).should == [{:genus=>{:string=>"Caulerpa"}, :species=>{:string=>"cupressoides"}, :infraspecies=>[{:string=>"nuda", :rank=>"f."}]}]
319
+ pos(sn).should == {0=>["genus", 8], 9=>["species", 21], 28=>["infraspecies", 32]}
320
+ sn = "Chlorocyperus glaber form. fasciculariforme (Lojac.) Soó"
321
+ parse(sn).should_not be_nil
322
+ value("Chlorocyperus glaber form. fasciculariforme (Lojac.) Soó").should == "Chlorocyperus glaber f. fasciculariforme (Lojac.) Soó"
323
+ canonical(sn).should == "Chlorocyperus glaber fasciculariforme"
324
+ details(sn).should == [{:genus=>{:string=>"Chlorocyperus"}, :species=>{:string=>"glaber"}, :infraspecies=>[{:string=>"fasciculariforme", :rank=>"f.", :authorship=>"(Lojac.) Soó", :combinationAuthorTeam=>{:authorTeam=>"Soó", :author=>["Soó"]}, :basionymAuthorTeam=>{:authorTeam=>"Lojac.", :author=>["Lojac."]}}]}]
325
+ pos(sn).should == {0=>["genus", 13], 14=>["species", 20], 27=>["infraspecies", 43], 45=>["author_word", 51], 53=>["author_word", 56]}
326
+ sn = "Bambusa nana Roxb. fo. alphonse-karri (Mitford ex Satow) Makino ex Shiros."
327
+ parse(sn).should_not be_nil
328
+ value(sn).should == "Bambusa nana Roxb. f. alphonse-karri (Mitford ex Satow) Makino ex Shiros."
329
+ canonical(sn).should == "Bambusa nana alphonse-karri"
330
+ details(sn).should == [{:genus=>{:string=>"Bambusa"}, :species=>{:string=>"nana", :authorship=>"Roxb.", :basionymAuthorTeam=>{:authorTeam=>"Roxb.", :author=>["Roxb."]}}, :infraspecies=>[{:string=>"alphonse-karri", :rank=>"f.", :authorship=>"(Mitford ex Satow) Makino ex Shiros.", :combinationAuthorTeam=>{:authorTeam=>"Makino", :author=>["Makino"], :exAuthorTeam=>{:authorTeam=>"Shiros.", :author=>["Shiros."]}}, :basionymAuthorTeam=>{:authorTeam=>"Mitford", :author=>["Mitford"], :exAuthorTeam=>{:authorTeam=>"Satow", :author=>["Satow"]}}}]}]
331
+ pos(sn).should == {0=>["genus", 7], 8=>["species", 12], 13=>["author_word", 18], 23=>["infraspecies", 37], 39=>["author_word", 46], 50=>["author_word", 55], 57=>["author_word", 63], 67=>["author_word", 74]}
332
+ sn = " Sphaerotheca fuliginea f. dahliae Movss. 1967 "
333
+ sn = "Sphaerotheca fuliginea f. dahliae Movss. 1967"
334
+ parse(sn).should_not be_nil
335
+ value(sn).should == "Sphaerotheca fuliginea f. dahliae Movss. 1967"
336
+ canonical(sn).should == "Sphaerotheca fuliginea dahliae"
337
+ details(sn).should == [{:genus=>{:string=>"Sphaerotheca"}, :species=>{:string=>"fuliginea"}, :infraspecies=>[{:string=>"dahliae", :rank=>"f.", :authorship=>"Movss. 1967", :basionymAuthorTeam=>{:authorTeam=>"Movss.", :author=>["Movss."], :year=>"1967"}}]}]
338
+ pos(sn).should == {0=>["genus", 12], 16=>["species", 25], 36=>["infraspecies", 43], 47=>["author_word", 53], 58=>["year", 62]}
339
+ parse('Polypodium vulgare nothosubsp. mantoniae (Rothm.) Schidlay').should_not be_nil
340
+ end
341
+
342
+ it "should parse name with several subspecies names NOT BOTANICAL CODE BUT NOT INFREQUENT" do
343
+ sn = "Hydnellum scrobiculatum var. zonatum f. parvum (Banker) D. Hall & D.E. Stuntz 1972"
344
+ parse(sn).should_not be_nil
345
+ value(sn).should == "Hydnellum scrobiculatum var. zonatum f. parvum (Banker) D. Hall et D.E. Stuntz 1972"
346
+ details(sn).should == [{:genus=>{:string=>"Hydnellum"}, :species=>{:string=>"scrobiculatum"}, :infraspecies=>[{:string=>"zonatum", :rank=>"var."}, {:string=>"parvum", :rank=>"f.", :authorship=>"(Banker) D. Hall & D.E. Stuntz 1972", :combinationAuthorTeam=>{:authorTeam=>"D. Hall & D.E. Stuntz", :author=>["D. Hall", "D.E. Stuntz"], :year=>"1972"}, :basionymAuthorTeam=>{:authorTeam=>"Banker", :author=>["Banker"]}}]}]
347
+ pos(sn).should == {0=>["genus", 9], 10=>["species", 23], 29=>["infraspecies", 36], 40=>["infraspecies", 46], 48=>["author_word", 54], 56=>["author_word", 58], 59=>["author_word", 63], 66=>["author_word", 70], 71=>["author_word", 77], 78=>["year", 82]}
348
+ parse('Senecio fuchsii C.C.Gmel. subsp. fuchsii var. expansus (Boiss. & Heldr.) Hayek').should_not be_nil
349
+ parse('Senecio fuchsii C.C.Gmel. subsp. fuchsii var. fuchsii').should_not be_nil
350
+ end
351
+
352
+
353
+ it "should parse status BOTANICAL RARE" do
354
+ #it is always latin abbrev often 2 words
355
+ sn = "Arthopyrenia hyalospora (Nyl.) R.C. Harris comb. nov."
356
+ parse(sn).should_not be_nil
357
+ value(sn).should == "Arthopyrenia hyalospora (Nyl.) R.C. Harris comb. nov."
358
+ canonical(sn).should == "Arthopyrenia hyalospora"
359
+ details(sn).should == [{:genus=>{:string=>"Arthopyrenia"}, :species=>{:string=>"hyalospora", :authorship=>"(Nyl.) R.C. Harris", :combinationAuthorTeam=>{:authorTeam=>"R.C. Harris ", :author=>["R.C. Harris"]}, :basionymAuthorTeam=>{:authorTeam=>"Nyl.", :author=>["Nyl."]}}, :status=>"comb. nov."}]
360
+ pos(sn).should == {0=>["genus", 12], 13=>["species", 23], 25=>["author_word", 29], 31=>["author_word", 35], 36=>["author_word", 42]}
361
+ end
362
+
363
+ it "should parse revised (ex) names" do
364
+ #invalidly published
365
+ sn = "Arthopyrenia hyalospora (Nyl. ex Banker) R.C. Harris"
366
+ parse(sn).should_not be_nil
367
+ value(sn).should == "Arthopyrenia hyalospora (Nyl. ex Banker) R.C. Harris"
368
+ canonical(sn).should == "Arthopyrenia hyalospora"
369
+ details(sn).should == [{:genus=>{:string=>"Arthopyrenia"}, :species=>{:string=>"hyalospora", :authorship=>"(Nyl. ex Banker) R.C. Harris", :combinationAuthorTeam=>{:authorTeam=>"R.C. Harris", :author=>["R.C. Harris"]}, :basionymAuthorTeam=>{:authorTeam=>"Nyl.", :author=>["Nyl."], :exAuthorTeam=>{:authorTeam=>"Banker", :author=>["Banker"]}}}}]
370
+ pos(sn).should == {0=>["genus", 12], 13=>["species", 23], 25=>["author_word", 29], 33=>["author_word", 39], 41=>["author_word", 45], 46=>["author_word", 52]}
371
+ sn = "Arthopyrenia hyalospora Nyl. ex Banker"
372
+ parse(sn).should_not be_nil
373
+ details(sn).should == [{:genus=>{:string=>"Arthopyrenia"}, :species=>{:string=>"hyalospora", :authorship=>"Nyl. ex Banker", :basionymAuthorTeam=>{:authorTeam=>"Nyl.", :author=>["Nyl."], :exAuthorTeam=>{:authorTeam=>"Banker", :author=>["Banker"]}}}}]
374
+ sn = "Glomopsis lonicerae Peck ex C.J. Gould 1945"
375
+ parse(sn).should_not be_nil
376
+ details(sn).should == [{:genus=>{:string=>"Glomopsis"}, :species=>{:string=>"lonicerae", :authorship=>"Peck ex C.J. Gould 1945", :basionymAuthorTeam=>{:authorTeam=>"Peck", :author=>["Peck"], :exAuthorTeam=>{:authorTeam=>"C.J. Gould", :author=>["C.J. Gould"], :year=>"1945"}}}}]
377
+ pos(sn).should == {0=>["genus", 9], 10=>["species", 19], 20=>["author_word", 24], 28=>["author_word", 32], 33=>["author_word", 38], 39=>["year", 43]}
378
+ parse("Acanthobasidium delicatum (Wakef.) Oberw. ex Jülich 1979").should_not be_nil
379
+ sn = "Mycosphaerella eryngii (Fr. ex Duby) Johanson ex Oudem. 1897"
380
+ parse(sn).should_not be_nil
381
+ details(sn).should == [{:genus=>{:string=>"Mycosphaerella"}, :species=>{:string=>"eryngii", :authorship=>"(Fr. ex Duby) Johanson ex Oudem. 1897", :combinationAuthorTeam=>{:authorTeam=>"Johanson", :author=>["Johanson"], :exAuthorTeam=>{:authorTeam=>"Oudem.", :author=>["Oudem."], :year=>"1897"}}, :basionymAuthorTeam=>{:authorTeam=>"Fr.", :author=>["Fr."], :exAuthorTeam=>{:authorTeam=>"Duby", :author=>["Duby"]}}}}]
382
+ pos(sn).should == {0=>["genus", 14], 15=>["species", 22], 24=>["author_word", 27], 31=>["author_word", 35], 37=>["author_word", 45], 49=>["author_word", 55], 56=>["year", 60]}
383
+ #invalid but happens
384
+ parse("Mycosphaerella eryngii (Fr. Duby) ex Oudem. 1897").should_not be_nil
385
+ parse("Mycosphaerella eryngii (Fr.ex Duby) ex Oudem. 1897").should_not be_nil
386
+ sn = "Salmonella werahensis (Castellani) Hauduroy and Ehringer in Hauduroy 1937"
387
+ parse(sn).should_not be_nil
388
+ details(sn).should == [{:genus=>{:string=>"Salmonella"}, :species=>{:string=>"werahensis", :authorship=>"(Castellani) Hauduroy and Ehringer in Hauduroy 1937", :combinationAuthorTeam=>{:authorTeam=>"Hauduroy and Ehringer", :author=>["Hauduroy", "Ehringer"], :exAuthorTeam=>{:authorTeam=>"Hauduroy", :author=>["Hauduroy"], :year=>"1937"}}, :basionymAuthorTeam=>{:authorTeam=>"Castellani", :author=>["Castellani"]}}}]
389
+ pos(sn).should == {0=>["genus", 10], 11=>["species", 21], 23=>["author_word", 33], 35=>["author_word", 43], 48=>["author_word", 56], 60=>["author_word", 68], 69=>["year", 73]}
390
+ end
391
+
392
+ it 'should parse named hybrids' do
393
+ [
394
+ ["×Agropogon P. Fourn. 1934", [{:uninomial=>{:string=>"Agropogon", :authorship=>"P. Fourn. 1934", :basionymAuthorTeam=>{:authorTeam=>"P. Fourn.", :author=>["P. Fourn."], :year=>"1934"}}}]],
395
+ ["xAgropogon P. Fourn.", [{:uninomial=>{:string=>"Agropogon", :authorship=>"P. Fourn.", :basionymAuthorTeam=>{:authorTeam=>"P. Fourn.", :author=>["P. Fourn."]}}}]],
396
+ ["XAgropogon P.Fourn.", [{:uninomial=>{:string=>"Agropogon", :authorship=>"P.Fourn.", :basionymAuthorTeam=>{:authorTeam=>"P.Fourn.", :author=>["P.Fourn."]}}}]],
397
+ ["× Agropogon", [{:uninomial=>{:string=>"Agropogon"}}]],
398
+ ["x Agropogon", [{:uninomial=>{:string=>"Agropogon"}}]],
399
+ ["X Agropogon", [{:uninomial=>{:string=>"Agropogon"}}]],
400
+ ["X Cupressocyparis leylandii", [{:genus=>{:string=>"Cupressocyparis"}, :species=>{:string=>"leylandii"}}]],
401
+ ["×Heucherella tiarelloides", [{:genus=>{:string=>"Heucherella"}, :species=>{:string=>"tiarelloides"}}]],
402
+ ["xHeucherella tiarelloides", [{:genus=>{:string=>"Heucherella"}, :species=>{:string=>"tiarelloides"}}]],
403
+ ["x Heucherella tiarelloides", [{:genus=>{:string=>"Heucherella"}, :species=>{:string=>"tiarelloides"}}]],
404
+ ["×Agropogon littoralis (Sm.) C. E. Hubb. 1946", [{:genus=>{:string=>"Agropogon"}, :species=>{:string=>"littoralis", :authorship=>"(Sm.) C. E. Hubb. 1946", :combinationAuthorTeam=>{:authorTeam=>"C. E. Hubb.", :author=>["C. E. Hubb."], :year=>"1946"}, :basionymAuthorTeam=>{:authorTeam=>"Sm.", :author=>["Sm."]}}}]]
405
+ ].each do |res|
406
+ parse(res[0]).should_not be_nil
407
+ parse(res[0]).hybrid.should be_true
408
+ details(res[0]).should == res[1]
409
+ end
410
+ [
411
+ ['Asplenium X inexpectatum (E.L. Braun 1940) Morton (1956)',[{:genus=>{:string=>"Asplenium"}, :species=>{:string=>"inexpectatum", :authorship=>"(E.L. Braun 1940) Morton (1956)", :combinationAuthorTeam=>{:authorTeam=>"Morton", :author=>["Morton"], :year=>"1956"}, :basionymAuthorTeam=>{:authorTeam=>"E.L. Braun", :author=>["E.L. Braun"], :year=>"1940"}}}]],
412
+ ['Mentha ×smithiana R. A. Graham 1949',[{:genus=>{:string=>"Mentha"}, :species=>{:string=>"smithiana", :authorship=>"R. A. Graham 1949", :basionymAuthorTeam=>{:authorTeam=>"R. A. Graham", :author=>["R. A. Graham"], :year=>"1949"}}}]],
413
+ ['Salix ×capreola Andersson (1867)',[{:genus=>{:string=>"Salix"}, :species=>{:string=>"capreola", :authorship=>"Andersson (1867)", :basionymAuthorTeam=>{:authorTeam=>"Andersson", :author=>["Andersson"], :year=>"1867"}}}]],
414
+ ['Salix x capreola Andersson',[{:genus=>{:string=>"Salix"}, :species=>{:string=>"capreola", :authorship=>"Andersson", :basionymAuthorTeam=>{:authorTeam=>"Andersson", :author=>["Andersson"]}}}]]
415
+ ].each do |res|
416
+ parse(res[0]).should_not be_nil
417
+ parse(res[0]).hybrid.should be_true
418
+ details(res[0]).should == res[1]
419
+ end
420
+ end
421
+
422
+ it "should parse hybrid combination" do
423
+ sn = "Arthopyrenia hyalospora X Hydnellum scrobiculatum"
424
+ parse(sn).should_not be_nil
425
+ parse(sn).hybrid.should be_true
426
+ value(sn).should == "Arthopyrenia hyalospora \303\227 Hydnellum scrobiculatum"
427
+ canonical(sn).should == "Arthopyrenia hyalospora Hydnellum scrobiculatum"
428
+ details(sn).should == [{:genus=>{:string=>"Arthopyrenia"}, :species=>{:string=>"hyalospora"}}, {:genus=>{:string=>"Hydnellum"}, :species=>{:string=>"scrobiculatum"}}]
429
+ pos(sn).should == {0=>["genus", 12], 13=>["species", 23], 26=>["genus", 35], 36=>["species", 49]}
430
+ sn = "Arthopyrenia hyalospora (Banker) D. Hall X Hydnellum scrobiculatum D.E. Stuntz"
431
+ parse(sn).should_not be_nil
432
+ parse(sn).hybrid.should be_true
433
+ value(sn).should == "Arthopyrenia hyalospora (Banker) D. Hall \303\227 Hydnellum scrobiculatum D.E. Stuntz"
434
+ canonical(sn).should == "Arthopyrenia hyalospora Hydnellum scrobiculatum"
435
+ pos(sn).should == {0=>["genus", 12], 13=>["species", 23], 25=>["author_word", 31], 33=>["author_word", 35], 36=>["author_word", 40], 43=>["genus", 52], 53=>["species", 66], 67=>["author_word", 71], 72=>["author_word", 78]}
436
+ value("Arthopyrenia hyalospora X").should == "Arthopyrenia hyalospora \303\227 ?"
437
+ sn = "Arthopyrenia hyalospora x"
438
+ parse(sn).should_not be_nil
439
+ parse(sn).hybrid.should be_true
440
+ canonical(sn).should == "Arthopyrenia hyalospora"
441
+ details(sn).should == [{:genus=>{:string=>"Arthopyrenia"}, :species=>{:string=>"hyalospora"}}, "?"]
442
+ pos(sn).should == {0=>["genus", 12], 13=>["species", 23]}
443
+ sn = "Arthopyrenia hyalospora × ?"
444
+ parse(sn).should_not be_nil
445
+ parse(sn).hybrid.should be_true
446
+ details(sn).should == [{:genus=>{:string=>"Arthopyrenia"}, :species=>{:string=>"hyalospora"}}, "?"]
447
+ pos(sn).should == {0=>["genus", 12], 13=>["species", 23]}
448
+ end
449
+
450
+ it 'should parse names with taxon concept' do
451
+ sn = "Sténométope laevissimus sec. Eschmeyer 2004"
452
+ val = @parser.failure_reason.to_s.match(/column [0-9]*/).to_s().gsub(/column /,'')
453
+ details(sn).should == [{:genus=>{:string=>"Sténométope"}, :species=>{:string=>"laevissimus"}, :taxon_concept=>{:authorship=>"Eschmeyer 2004", :basionymAuthorTeam=>{:authorTeam=>"Eschmeyer", :author=>["Eschmeyer"], :year=>"2004"}}}]
454
+ pos(sn).should == {0=>["genus", 11], 12=>["species", 23], 29=>["author_word", 38], 39=>["year", 43]}
455
+ sn = "Sténométope laevissimus Bibron 1855 sec. Eschmeyer 2004"
456
+ parse(sn).should_not be_nil
457
+ details(sn).should == [{:genus=>{:string=>"Sténométope"}, :species=>{:string=>"laevissimus", :authorship=>"Bibron 1855", :basionymAuthorTeam=>{:authorTeam=>"Bibron", :author=>["Bibron"], :year=>"1855"}}, :taxon_concept=>{:authorship=>"Eschmeyer 2004", :basionymAuthorTeam=>{:authorTeam=>"Eschmeyer", :author=>["Eschmeyer"], :year=>"2004"}}}]
458
+ pos(sn).should == {0=>["genus", 11], 12=>["species", 23], 24=>["author_word", 30], 31=>["year", 35], 41=>["author_word", 50], 51=>["year", 55]}
459
+ end
460
+
461
+ it 'should parse names with spaces inconsistencies at the start and the end and in the middle' do
462
+ parse(" Asplenium X inexpectatum (E.L. Braun 1940) Morton (1956) ").should_not be_nil
463
+ end
464
+
465
+ it 'should not parse serveral authors groups with several years NOT CORRECT' do
466
+ parse("Pseudocercospora dendrobii (H.C. Burnett 1883) (Leight.) (Movss. 1967) U. Braun & Crous 2003").should be_nil
467
+ end
468
+
469
+ it "should not parse unallowed utf-8 chars in name part" do
470
+ parse("Érematosphaeria phaespora").should be_nil
471
+ parse("Trematosphaeria phaeáapora").should be_nil
472
+ parse("Trematоsphaeria phaeáapora").should be_nil #cyrillic o
473
+ end
474
+
475
+ it "should parse new stuff" do
476
+ sn = 'Nesticus quelpartensis Paik & Namkung, in Paik, Yaginuma & Namkung, 1969'
477
+ details(sn).should == [{:genus=>{:string=>"Nesticus"}, :species=>{:string=>"quelpartensis", :authorship=>"Paik & Namkung, in Paik, Yaginuma & Namkung, 1969", :basionymAuthorTeam=>{:authorTeam=>"Paik & Namkung", :author=>["Paik", "Namkung"], :exAuthorTeam=>{:authorTeam=>"Paik, Yaginuma & Namkung", :author=>["Paik", "Yaginuma", "Namkung"], :year=>"1969"}}}}]
478
+ parse('Dipoena yoshidai Ono, in Ono et al., 1991').should_not be_nil
479
+ sn = 'Choriozopella trägårdhi Lawrence, 1947'
480
+ details(sn).should == [{:genus=>{:string=>"Choriozopella"}, :species=>{:string=>"trägårdhi", :authorship=>"Lawrence, 1947", :basionymAuthorTeam=>{:authorTeam=>"Lawrence", :author=>["Lawrence"], :year=>"1947"}}}]
481
+ sn = 'Latrodectus mactans bishopi Kaston, 1938'
482
+ details(sn).should == [{:genus=>{:string=>"Latrodectus"}, :species=>{:string=>"mactans"}, :infraspecies=>[{:string=>"bishopi", :rank=>"n/a", :authorship=>"Kaston, 1938", :basionymAuthorTeam=>{:authorTeam=>"Kaston", :author=>["Kaston"], :year=>"1938"}}]}]
483
+ sn = 'Diplocephalus aff. procerus Thaler, 1972'
484
+ details(sn).should == [{:genus=>{:string=>"Diplocephalus"}, :species=>{:string=>"procerus", :authorship=>"Thaler, 1972", :basionymAuthorTeam=>{:authorTeam=>"Thaler", :author=>["Thaler"], :year=>"1972"}}}]
485
+ sn = 'Dyarcyops birói Kulczynski, 1908'
486
+ details(sn).should == [{:genus=>{:string=>"Dyarcyops"}, :species=>{:string=>"birói", :authorship=>"Kulczynski, 1908", :basionymAuthorTeam=>{:authorTeam=>"Kulczynski", :author=>["Kulczynski"], :year=>"1908"}}}]
487
+ sn = 'Sparassus françoisi Simon, 1898'
488
+ details(sn).should == [{:genus=>{:string=>"Sparassus"}, :species=>{:string=>"françoisi", :authorship=>"Simon, 1898", :basionymAuthorTeam=>{:authorTeam=>"Simon", :author=>["Simon"], :year=>"1898"}}}]
489
+ sn = 'Thiobacillus x Parker and Prisk 1953' #have to figure out black lists for this one
490
+ sn = 'Bacille de Plaut, Kritchevsky and Séguin 1921'
491
+ details(sn).should == [{:uninomial=>{:string=>"Bacille", :authorship=>"de Plaut, Kritchevsky and Séguin 1921", :basionymAuthorTeam=>{:authorTeam=>"de Plaut, Kritchevsky and Séguin", :author=>["de Plaut", "Kritchevsky", "Séguin"], :year=>"1921"}}}]
492
+ sn = 'Araneus van bruysseli Petrunkevitch, 1911'
493
+ details(sn).should == [{:genus=>{:string=>"Araneus"}, :species=>{:string=>"van"}, :infraspecies=>[{:string=>"bruysseli", :rank=>"n/a", :authorship=>"Petrunkevitch, 1911", :basionymAuthorTeam=>{:authorTeam=>"Petrunkevitch", :author=>["Petrunkevitch"], :year=>"1911"}}]}]
494
+ sn = 'Sapromyces laidlawi ab Sabin 1941'
495
+ details(sn).should == [{:genus=>{:string=>"Sapromyces"}, :species=>{:string=>"laidlawi", :authorship=>"ab Sabin 1941", :basionymAuthorTeam=>{:authorTeam=>"ab Sabin", :author=>["ab Sabin"], :year=>"1941"}}}]
496
+ sn = 'Nocardia rugosa di Marco and Spalla 1957'
497
+ details(sn).should == [{:genus=>{:string=>"Nocardia"}, :species=>{:string=>"rugosa", :authorship=>"di Marco and Spalla 1957", :basionymAuthorTeam=>{:authorTeam=>"di Marco and Spalla", :author=>["di Marco", "Spalla"], :year=>"1957"}}}]
498
+ sn = 'Flexibacter elegans Lewin 1969 non Soriano 1945'
499
+ details(sn).should == [{:genus=>{:string=>"Flexibacter"}, :species=>{:string=>"elegans", :authorship=>"Lewin 1969 non Soriano 1945", :basionymAuthorTeam=>{:authorTeam=>"Lewin", :author=>["Lewin"], :year=>"1969"}}}]
500
+ sn = 'Flexibacter elegans Soriano 1945, non Lewin 1969'
501
+ details(sn).should == [{:genus=>{:string=>"Flexibacter"}, :species=>{:string=>"elegans", :authorship=>"Soriano 1945, non Lewin 1969", :basionymAuthorTeam=>{:authorTeam=>"Soriano", :author=>["Soriano"], :year=>"1945"}}}]
502
+ end
503
+
504
+ end
@@ -0,0 +1,90 @@
1
+ # encoding: UTF-8
2
+ dir = File.dirname("__FILE__")
3
+ require File.expand_path(dir + '../../spec/parser/spec_helper')
4
+
5
+ describe ScientificNameDirty do
6
+ before(:all) do
7
+ set_parser(ScientificNameDirtyParser.new)
8
+ end
9
+
10
+
11
+ it 'should parse clean names' do
12
+ parse("Betula verucosa (L.) Bar. 1899").should_not be_nil
13
+ end
14
+
15
+ it 'should parse double parenthesis' do
16
+ sn = "Eichornia crassipes ( (Martius) ) Solms-Laub."
17
+ parse(sn).should_not be_nil
18
+ value(sn).should == "Eichornia crassipes (Martius) Solms-Laub."
19
+ details(sn).should == [{:genus=>{:string=>"Eichornia"}, :species=>{:string=>"crassipes", :authorship=>"( (Martius) ) Solms-Laub.", :combinationAuthorTeam=>{:authorTeam=>"Solms-Laub.", :author=>["Solms-Laub."]}, :basionymAuthorTeam=>{:authorTeam=>"Martius", :author=>["Martius"]}}}]
20
+ pos(sn).should == {0=>["genus", 9], 10=>["species", 19], 23=>["author_word", 30], 34=>["author_word", 45]}
21
+ end
22
+
23
+ it "should parse year without author" do
24
+ sn = "Acarospora cratericola 1929"
25
+ parse(sn).should_not be_nil
26
+ pos(sn).should == {0=>["genus", 10], 11=>["species", 22], 23=>["year", 27]}
27
+ details(sn).should == [{:genus=>{:string=>"Acarospora"}, :species=>{:string=>"cratericola", :year=>"1929"}}]
28
+ end
29
+
30
+ it 'should parse double years' do
31
+ sn = "Tridentella tangeroae Bruce, 1987-92"
32
+ parse(sn).should_not be_nil
33
+ pos(sn).should == {0=>["genus", 11], 12=>["species", 21], 22=>["author_word", 27], 29=>["year", 36]}
34
+ details(sn).should == [{:genus=>{:string=>"Tridentella"}, :species=>{:string=>"tangeroae", :authorship=>"Bruce, 1987-92", :basionymAuthorTeam=>{:authorTeam=>"Bruce", :author=>["Bruce"], :year=>"1987-92"}}}]
35
+ end
36
+
37
+ it 'should parse dirty years' do
38
+ parse("Tridentella tangeroae Bruce, 1988B").should_not be_nil
39
+ parse("Tridentella tangeroae Bruce, 1988b").should_not be_nil
40
+ parse("Tridentella tangeroae Bruce, 1988d").should_not be_nil
41
+ sn = "Tridentella tangeroae Bruce, 198?"
42
+ parse(sn).should_not be_nil
43
+ pos(sn).should == {0=>["genus", 11], 12=>["species", 21], 22=>["author_word", 27], 29=>["year", 33]}
44
+ end
45
+
46
+ it 'should parse year with page number' do
47
+ sn = "Gymnodactylus irregularis WERMUTH 1965: 54"
48
+ parse(sn).should_not be_nil
49
+ value(sn).should == "Gymnodactylus irregularis WERMUTH 1965"
50
+ details(sn).should == [{:genus=>{:string=>"Gymnodactylus"}, :species=>{:string=>"irregularis", :authorship=>"WERMUTH 1965: 54", :basionymAuthorTeam=>{:authorTeam=>"WERMUTH", :author=>["WERMUTH"], :year=>"1965"}}}]
51
+ pos(sn).should == {0=>["genus", 13], 14=>["species", 25], 26=>["author_word", 33], 34=>["year", 38]}
52
+ end
53
+
54
+ it 'should parse year with []' do
55
+ parse("Anthoscopus Cabanis [1851]").should_not be_nil
56
+ value("Anthoscopus Cabanis [185?]").should == "Anthoscopus Cabanis (185?)"
57
+ parse("Anthoscopus Cabanis [1851?]").should_not be_nil
58
+ value("Anthoscopus Cabanis [1851]").should == "Anthoscopus Cabanis (1851)"
59
+ sn = "Anthoscopus Cabanis [1851?]"
60
+ value(sn).should == "Anthoscopus Cabanis (1851?)"
61
+ details(sn).should == [{:uninomial=>{:string=>"Anthoscopus", :authorship=>"Cabanis [1851?]", :basionymAuthorTeam=>{:authorTeam=>"Cabanis", :author=>["Cabanis"], :approximate_year=>"(1851?)"}}}]
62
+ pos(sn).should == {0=>["uninomial", 11], 12=>["author_word", 19], 21=>["year", 26]}
63
+ sn = "Trismegistia monodii Ando, 1973 [1974]"
64
+ parse(sn).should_not be_nil
65
+ value(sn).should == 'Trismegistia monodii Ando 1973 (1974)' #should it be 'Trismegistia monodii Ando 1973 (1974)' instead?
66
+ details(sn).should == [{:genus=>{:string=>"Trismegistia"}, :species=>{:string=>"monodii", :authorship=>"Ando, 1973 [1974]", :basionymAuthorTeam=>{:authorTeam=>"Ando", :author=>["Ando"], :year=>"1973", :approximate_year=>"(1974)"}}}]
67
+ pos(sn).should == {0=>["genus", 12], 13=>["species", 20], 21=>["author_word", 25], 27=>["year", 31], 33=>["year", 37]}
68
+ parse("Zygaena witti Wiegel [1973]").should_not be_nil
69
+ sn = "Deyeuxia coarctata Kunth, 1815 [1816]"
70
+ parse(sn).should_not be_nil
71
+ pos(sn).should == {0=>["genus", 8], 9=>["species", 18], 19=>["author_word", 24], 26=>["year", 30], 32=>["year", 36]}
72
+ end
73
+
74
+ it "should parse new stuff" do
75
+ sn = 'Zoropsis (TaKeoa) nishimurai Yaginuma, 1971' #skipping for now
76
+ sn = 'Campylobacter pyloridis Marshall et al.1985.'
77
+ details(sn).should == [{:genus=>{:string=>"Campylobacter"}, :species=>{:string=>"pyloridis", :authorship=>"Marshall et al.1985.", :basionymAuthorTeam=>{:authorTeam=>"Marshall et al.", :author=>["Marshall et al."], :year=>"1985"}}}]
78
+ sn = 'Staphylococcus hyicus chromogenes Devriese et al. 1978 (Approved Lists 1980).'
79
+ details(sn).should == [{:genus=>{:string=>"Staphylococcus"}, :species=>{:string=>"hyicus"}, :infraspecies=>[{:string=>"chromogenes", :rank=>"n/a", :authorship=>"Devriese et al. 1978", :basionymAuthorTeam=>{:authorTeam=>"Devriese et al.", :author=>["Devriese et al."], :year=>"1978"}}]}]
80
+ sn = 'Kitasatospora corrig. griseola Takahashi et al. 1985.'
81
+ details(sn).should == [{:genus=>{:string=>"Kitasatospora"}, :species=>{:string=>"griseola", :authorship=>"Takahashi et al. 1985.", :basionymAuthorTeam=>{:authorTeam=>"Takahashi et al.", :author=>["Takahashi et al."], :year=>"1985"}}}]
82
+ sn = 'Beijerinckia derxii venezuelae corrig. Thompson and Skerman, 1981'
83
+ details(sn).should == [{:genus=>{:string=>"Beijerinckia"}, :species=>{:string=>"derxii"}, :infraspecies=>[{:string=>"venezuelae", :rank=>"n/a", :authorship=>"Thompson and Skerman, 1981", :basionymAuthorTeam=>{:authorTeam=>"Thompson and Skerman", :author=>["Thompson", "Skerman"], :year=>"1981"}}]}]
84
+ details('Streptomyces parvisporogenes ignotus 1960').should == [{:genus=>{:string=>"Streptomyces"}, :species=>{:string=>"parvisporogenes"}, :infraspecies=>[{:string=>"ignotus", :rank=>"n/a", :year=>"1960"}]}]
85
+ details('Oscillaria caviae Simons 1920, according to Simons 1922').should == [{:genus=>{:string=>"Oscillaria"}, :species=>{:string=>"caviae", :authorship=>"Simons 1920", :basionymAuthorTeam=>{:authorTeam=>"Simons", :author=>["Simons"], :year=>"1920"}}}]
86
+ sn = 'Bacterium monocytogenes hominis"" Nyfeldt 1932'
87
+ details(sn).should == [{:genus=>{:string=>"Bacterium"}, :species=>{:string=>"monocytogenes"}, :infraspecies=>[{:string=>"hominis", :rank=>"n/a"}]}]
88
+ end
89
+
90
+ end