dimus-biodiversity 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -1
- data/bin/nnparse +2 -1
- data/lib/biodiversity/parser.rb +19 -1
- data/lib/biodiversity/parser/scientific_name_canonical.rb +214 -0
- data/lib/biodiversity/parser/scientific_name_canonical.treetop +40 -0
- data/lib/biodiversity/parser/{scientific_name.rb → scientific_name_clean.rb} +1432 -369
- data/lib/biodiversity/parser/{scientific_name.treetop → scientific_name_clean.treetop} +197 -18
- data/lib/biodiversity/parser/scientific_name_dirty.rb +473 -0
- data/lib/biodiversity/parser/scientific_name_dirty.treetop +80 -0
- data/spec/parser/scientific_name.spec.rb +14 -252
- data/spec/parser/scientific_name_canonical.spec.rb +43 -0
- data/spec/parser/scientific_name_clean.spec.rb +393 -0
- data/spec/parser/scientific_name_dirty.spec.rb +90 -0
- metadata +10 -3
@@ -0,0 +1,90 @@
|
|
1
|
+
dir = File.dirname("__FILE__")
|
2
|
+
require 'rubygems'
|
3
|
+
require 'spec'
|
4
|
+
require 'treetop'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
Treetop.load(File.expand_path(dir + '../../lib/biodiversity/parser/scientific_name_clean'))
|
8
|
+
Treetop.load(File.expand_path(dir + '../../lib/biodiversity/parser/scientific_name_dirty'))
|
9
|
+
|
10
|
+
describe ScientificNameDirty do
|
11
|
+
before(:all) do
|
12
|
+
@parser = ScientificNameDirtyParser.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse(input)
|
16
|
+
@parser.parse(input)
|
17
|
+
end
|
18
|
+
|
19
|
+
def value(input)
|
20
|
+
parse(input).value
|
21
|
+
end
|
22
|
+
|
23
|
+
def canonical(input)
|
24
|
+
parse(input).canonical
|
25
|
+
end
|
26
|
+
|
27
|
+
def details(input)
|
28
|
+
parse(input).details
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should parse clean names' do
|
32
|
+
parse("Betula verucose (L.) Bar. 1899").should_not be_nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should parse year with []' do
|
36
|
+
parse("Anthoscopus Cabanis [1851]").should_not be_nil
|
37
|
+
value("Anthoscopus Cabanis [185?]").should == "Anthoscopus Cabanis (185?)"
|
38
|
+
parse("Anthoscopus Cabanis [1851?]").should_not be_nil
|
39
|
+
value("Anthoscopus Cabanis [1851]").should == "Anthoscopus Cabanis (1851)"
|
40
|
+
value("Anthoscopus Cabanis [1851?]").should == "Anthoscopus Cabanis (1851?)"
|
41
|
+
details("Anthoscopus Cabanis [1851?]").should == {:uninomial=>"Anthoscopus", :authors=>{:names=>["Cabanis"], :approximate_year=>"(1851?)"}, :name_part_verbatim=>"Anthoscopus", :auth_part_verbatim=>"Cabanis [1851?]"}
|
42
|
+
|
43
|
+
parse("Trismegistia monodii Ando, 1973 [1974]").should_not be_nil
|
44
|
+
details("Trismegistia monodii Ando, 1973 [1974]").should == {:genus=>"Trismegistia", :species=>"monodii", :authors=>{:names=>["Ando"], :ambiguous_year=>"1973 [1974]"}, :name_part_verbatim=>"Trismegistia monodii", :auth_part_verbatim=>"Ando, 1973 [1974]"}
|
45
|
+
parse("Zygaena witti Wiegel [1973]").should_not be_nil
|
46
|
+
parse("Deyeuxia coarctata Kunth, 1815 [1816]").should_not be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should parse year with page number' do
|
50
|
+
val = "Gymnodactylus irregularis WERMUTH 1965: 54"
|
51
|
+
parse(val).should_not be_nil
|
52
|
+
value(val).should == "Gymnodactylus irregularis WERMUTH 1965"
|
53
|
+
details(val).should == {:genus=>"Gymnodactylus", :species=>"irregularis", :authors=>{:names=>["WERMUTH"], :year=>"1965"}, :name_part_verbatim=>"Gymnodactylus irregularis", :auth_part_verbatim=>"WERMUTH 1965: 54"}
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should parse double parenthesis' do
|
57
|
+
val = "Meiostemon humbertii ( (H. Perrier) ) Exell & Stace"
|
58
|
+
parse(val).should_not be_nil
|
59
|
+
value(val).should == "Meiostemon humbertii (H. Perrier) Exell et Stace"
|
60
|
+
details(val).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"}
|
61
|
+
end
|
62
|
+
|
63
|
+
# Acomys "Geoffroy, I." 1838
|
64
|
+
# Verpericola megasoma "Dall" Pils.
|
65
|
+
# Auricotes neoclayae "Price, Hellenthal and Palma 2003"
|
66
|
+
# Leccinum cinnamomeum var. cinnamomeum "A.H. Sm.
|
67
|
+
|
68
|
+
# it 'should parse quote' do
|
69
|
+
# val = 'Acomys "Geoffroy, I." 1838'
|
70
|
+
# end
|
71
|
+
|
72
|
+
# it 'should parse author with []' do
|
73
|
+
# # OK parse("Farsetia mutabilis [ R.Br. ]").should_not be_nil
|
74
|
+
# parse("Farsetia mutabilis [R.Br.]").should_not be_nil
|
75
|
+
# # value("Farsetia mutabilis [R.Br.]").should == "Farsetia mutabilis [R.Br.]"
|
76
|
+
# # details("Farsetia mutabilis [R.Br.]").should == {}
|
77
|
+
# end
|
78
|
+
|
79
|
+
it 'should parse dirty years' do
|
80
|
+
parse("Tridentella tangeroae Bruce, 1988B").should_not be_nil
|
81
|
+
parse("Tridentella tangeroae Bruce, 1988b").should_not be_nil
|
82
|
+
parse("Tridentella tangeroae Bruce, 1988d").should_not be_nil
|
83
|
+
parse("Tridentella tangeroae Bruce, 198?").should_not be_nil
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should parse double years' do
|
87
|
+
parse("Tridentella tangeroae Bruce, 1987-92").should_not be_nil
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dimus-biodiversity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Mozzherin
|
@@ -38,6 +38,9 @@ files:
|
|
38
38
|
- conf/environment.rb
|
39
39
|
- spec/parser
|
40
40
|
- spec/parser/scientific_name.spec.rb
|
41
|
+
- spec/parser/scientific_name_canonical.spec.rb
|
42
|
+
- spec/parser/scientific_name_clean.spec.rb
|
43
|
+
- spec/parser/scientific_name_dirty.spec.rb
|
41
44
|
- spec/guid
|
42
45
|
- spec/guid/lsid.spec.rb
|
43
46
|
- lib/biodiversity
|
@@ -45,8 +48,12 @@ files:
|
|
45
48
|
- lib/biodiversity/guid.rb
|
46
49
|
- lib/biodiversity/guid
|
47
50
|
- lib/biodiversity/guid/lsid.rb
|
48
|
-
- lib/biodiversity/parser/
|
49
|
-
- lib/biodiversity/parser/
|
51
|
+
- lib/biodiversity/parser/scientific_name_clean.rb
|
52
|
+
- lib/biodiversity/parser/scientific_name_canonical.rb
|
53
|
+
- lib/biodiversity/parser/scientific_name_dirty.rb
|
54
|
+
- lib/biodiversity/parser/scientific_name_canonical.treetop
|
55
|
+
- lib/biodiversity/parser/scientific_name_clean.treetop
|
56
|
+
- lib/biodiversity/parser/scientific_name_dirty.treetop
|
50
57
|
- lib/biodiversity/parser.rb
|
51
58
|
- lib/biodiversity.rb
|
52
59
|
- bin/nnparse
|