dimus-biodiversity 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/biodiversity/parser.rb +35 -2
- data/lib/biodiversity/parser/scientific_name_canonical.rb +10 -0
- data/lib/biodiversity/parser/scientific_name_canonical.treetop +10 -0
- data/lib/biodiversity/parser/scientific_name_clean.rb +404 -132
- data/lib/biodiversity/parser/scientific_name_clean.treetop +218 -11
- data/lib/biodiversity/parser/scientific_name_dirty.rb +18 -0
- data/lib/biodiversity/parser/scientific_name_dirty.treetop +18 -0
- data/spec/parser/scientific_name.spec.rb +13 -1
- data/spec/parser/scientific_name_canonical.spec.rb +7 -2
- data/spec/parser/scientific_name_clean.spec.rb +206 -122
- data/spec/parser/scientific_name_dirty.spec.rb +32 -16
- metadata +1 -1
@@ -28,6 +28,10 @@ describe ScientificNameDirty do
|
|
28
28
|
parse(input).details
|
29
29
|
end
|
30
30
|
|
31
|
+
def pos(input)
|
32
|
+
parse(input).pos
|
33
|
+
end
|
34
|
+
|
31
35
|
it 'should parse clean names' do
|
32
36
|
parse("Betula verucose (L.) Bar. 1899").should_not be_nil
|
33
37
|
end
|
@@ -37,27 +41,35 @@ describe ScientificNameDirty do
|
|
37
41
|
value("Anthoscopus Cabanis [185?]").should == "Anthoscopus Cabanis (185?)"
|
38
42
|
parse("Anthoscopus Cabanis [1851?]").should_not be_nil
|
39
43
|
value("Anthoscopus Cabanis [1851]").should == "Anthoscopus Cabanis (1851)"
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
44
|
+
sn = "Anthoscopus Cabanis [1851?]"
|
45
|
+
value(sn).should == "Anthoscopus Cabanis (1851?)"
|
46
|
+
details(sn).should == {:uninomial=>"Anthoscopus", :authors=>{:names=>["Cabanis"], :approximate_year=>"(1851?)"}, :name_part_verbatim=>"Anthoscopus", :auth_part_verbatim=>"Cabanis [1851?]"}
|
47
|
+
pos(sn).should == {0=>["uninomial", 11], 12=>["author_word", 19], 21=>["year", 26]}
|
48
|
+
sn = "Trismegistia monodii Ando, 1973 [1974]"
|
49
|
+
parse(sn).should_not be_nil
|
50
|
+
value(sn).should == 'Trismegistia monodii Ando 1973 [1974]' #should it be 'Trismegistia monodii Ando 1973 (1974)' instead?
|
51
|
+
details(sn).should == {:genus=>"Trismegistia", :species=>"monodii", :authors=>{:names=>["Ando"], :ambiguous_year=>"1973 [1974]"}, :name_part_verbatim=>"Trismegistia monodii", :auth_part_verbatim=>"Ando, 1973 [1974]"}
|
52
|
+
pos(sn).should == {0=>["genus", 12], 13=>["species", 20], 21=>["author_word", 25], 27=>["year", 31], 33=>["year", 37]}
|
45
53
|
parse("Zygaena witti Wiegel [1973]").should_not be_nil
|
46
|
-
|
54
|
+
sn = "Deyeuxia coarctata Kunth, 1815 [1816]"
|
55
|
+
parse(sn).should_not be_nil
|
56
|
+
pos(sn).should == {0=>["genus", 8], 9=>["species", 18], 19=>["author_word", 24], 26=>["year", 30], 32=>["year", 36]}
|
47
57
|
end
|
48
58
|
|
49
59
|
it 'should parse year with page number' do
|
50
|
-
|
51
|
-
parse(
|
52
|
-
value(
|
53
|
-
details(
|
60
|
+
sn = "Gymnodactylus irregularis WERMUTH 1965: 54"
|
61
|
+
parse(sn).should_not be_nil
|
62
|
+
value(sn).should == "Gymnodactylus irregularis WERMUTH 1965"
|
63
|
+
details(sn).should == {:genus=>"Gymnodactylus", :species=>"irregularis", :authors=>{:names=>["WERMUTH"], :year=>"1965"}, :name_part_verbatim=>"Gymnodactylus irregularis", :auth_part_verbatim=>"WERMUTH 1965: 54"}
|
64
|
+
pos(sn).should == {0=>["genus", 13], 14=>["species", 25], 26=>["author_word", 33], 34=>["year", 38]}
|
54
65
|
end
|
55
66
|
|
56
67
|
it 'should parse double parenthesis' do
|
57
|
-
|
58
|
-
parse(
|
59
|
-
value(
|
60
|
-
details(
|
68
|
+
sn = "Meiostemon humbertii ( (H. Perrier) ) Exell & Stace"
|
69
|
+
parse(sn).should_not be_nil
|
70
|
+
value(sn).should == "Meiostemon humbertii (H. Perrier) Exell et Stace"
|
71
|
+
details(sn).should == {:genus=>"Meiostemon", :species=>"humbertii", :orig_authors=>{:names=>["H. Perrier"]}, :authors=>{:names=>["Exell", "Stace"]}, :name_part_verbatim=>"Meiostemon humbertii", :auth_part_verbatim=>"( (H. Perrier) ) Exell & Stace"}
|
72
|
+
pos(sn).should == {0=>["genus", 10], 11=>["species", 20], 24=>["author_word", 26], 27=>["author_word", 34], 38=>["author_word", 43], 46=>["author_word", 51]}
|
61
73
|
end
|
62
74
|
|
63
75
|
# Acomys "Geoffroy, I." 1838
|
@@ -80,11 +92,15 @@ describe ScientificNameDirty do
|
|
80
92
|
parse("Tridentella tangeroae Bruce, 1988B").should_not be_nil
|
81
93
|
parse("Tridentella tangeroae Bruce, 1988b").should_not be_nil
|
82
94
|
parse("Tridentella tangeroae Bruce, 1988d").should_not be_nil
|
83
|
-
|
95
|
+
sn = "Tridentella tangeroae Bruce, 198?"
|
96
|
+
parse(sn).should_not be_nil
|
97
|
+
pos(sn).should == {0=>["genus", 11], 12=>["species", 21], 22=>["author_word", 27], 29=>["year", 33]}
|
84
98
|
end
|
85
99
|
|
86
100
|
it 'should parse double years' do
|
87
|
-
|
101
|
+
sn = "Tridentella tangeroae Bruce, 1987-92"
|
102
|
+
parse(sn).should_not be_nil
|
103
|
+
pos(sn).should == {0=>["genus", 11], 12=>["species", 21], 22=>["author_word", 27], 29=>["year", 36]}
|
88
104
|
end
|
89
105
|
|
90
106
|
end
|