taxamatch_rb 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.4
1
+ 0.8.5
@@ -62,11 +62,17 @@ module Taxamatch
62
62
  res[:years] = []
63
63
  [:basionymAuthorTeam, :combinationAuthorTeam].each do |au|
64
64
  if node[au]
65
- res[:authors] += node[au][:author]
66
- res[:years] << node[au][:year] if node[au][:year]
65
+ res[:authors] += node[au][:author]
66
+ if node[au][:year]
67
+ year = Taxamatch::Normalizer.normalize_year(node[au][:year])
68
+ res[:years] << year if year
69
+ end
67
70
  if node[au][:exAuthorTeam]
68
71
  res[:authors] += node[au][:exAuthorTeam][:author]
69
- res[:years] << node[au][:exAuthorTeam][:year] if node[au][:exAuthorTeam][:year]
72
+ if node[au][:exAuthorTeam][:year]
73
+ year = Taxamatch::Normalizer.normalize_year(node[:exAuthorTeam][:year])
74
+ res[:years] << year if year
75
+ end
70
76
  end
71
77
  end
72
78
  end
@@ -15,7 +15,14 @@ module Taxamatch
15
15
  self.normalize(string).gsub(/[^A-Z]/, ' ').gsub(/[\s]{2,}/, ' ').strip
16
16
  end
17
17
 
18
- protected
18
+ def self.normalize_year(year_string)
19
+ year_int = year_string.gsub(/[^\d]/, '').to_i
20
+ year_int = nil unless year_int.between?(1757, Time.now.year + 1)
21
+ year_int
22
+ end
23
+
24
+
25
+ private
19
26
  def self.utf8_to_ascii(string)
20
27
  string = string.gsub(/\s{2,}/, ' ')
21
28
  string = string.gsub(/[ÀÂÅÃÄÁẤẠ]/, "A")
@@ -8,15 +8,20 @@ describe 'Atomizer' do
8
8
 
9
9
  it 'should parse uninomials' do
10
10
  @parser.parse('Betula').should == {:all_authors=>[], :all_years=>[], :uninomial=>{:string=>"Betula", :normalized=>"BETULA", :phonetized=>"BITILA", :authors=>[], :years=>[], :normalized_authors=>[]}}
11
- @parser.parse('Ærenea Lacordaire, 1872').should == {:all_authors=>["LACORDAIRE"], :all_years=>["1872"], :uninomial=>{:string=>"Aerenea", :normalized=>"AERENEA", :phonetized=>"ERINIA", :authors=>["Lacordaire"], :years=>["1872"], :normalized_authors=>["LACORDAIRE"]}}
11
+ @parser.parse('Ærenea Lacordaire, 1872').should == {:all_authors=>["LACORDAIRE"], :all_years=>[1872], :uninomial=>{:string=>"Aerenea", :normalized=>"AERENEA", :phonetized=>"ERINIA", :authors=>["Lacordaire"], :years=>[1872], :normalized_authors=>["LACORDAIRE"]}}
12
12
  end
13
13
 
14
14
  it 'should parse binomials' do
15
- @parser.parse('Leœptura laetifica Dow, 1913').should == {:all_authors=>["DOW"], :all_years=>["1913"], :genus=>{:string=>"Leoeptura", :normalized=>"LEOEPTURA", :phonetized=>"LIPTIRA", :authors=>[], :years=>[], :normalized_authors=>[]}, :species=>{:string=>"laetifica", :normalized=>"LAETIFICA", :phonetized=>"LITIFICA", :authors=>["Dow"], :years=>["1913"], :normalized_authors=>["DOW"]}}
15
+ @parser.parse('Leœptura laetifica Dow, 1913').should == {:all_authors=>["DOW"], :all_years=>[1913], :genus=>{:string=>"Leoeptura", :normalized=>"LEOEPTURA", :phonetized=>"LIPTIRA", :authors=>[], :years=>[], :normalized_authors=>[]}, :species=>{:string=>"laetifica", :normalized=>"LAETIFICA", :phonetized=>"LITIFICA", :authors=>["Dow"], :years=>[1913], :normalized_authors=>["DOW"]}}
16
16
  end
17
17
 
18
18
  it 'should parse trinomials' do
19
- @parser.parse('Hydnellum scrobiculatum zonatum (Banker) D. Hall et D.E. Stuntz 1972').should == {:all_authors=>["BANKER", "D HALL", "D E STUNTZ"], :all_years=>["1972"], :genus=>{:string=>"Hydnellum", :normalized=>"HYDNELLUM", :phonetized=>"HIDNILIM", :authors=>[], :years=>[], :normalized_authors=>[]}, :species=>{:string=>"scrobiculatum", :normalized=>"SCROBICULATUM", :phonetized=>"SCRABICILATA", :authors=>[], :years=>[], :normalized_authors=>[]}, :infraspecies=>[{:string=>"zonatum", :normalized=>"ZONATUM", :phonetized=>"ZANATA", :authors=>["Banker", "D. Hall", "D.E. Stuntz"], :years=>["1972"], :normalized_authors=>["BANKER", "D HALL", "D E STUNTZ"]}]}
19
+ @parser.parse('Hydnellum scrobiculatum zonatum (Banker) D. Hall et D.E. Stuntz 1972').should == {:all_authors=>["BANKER", "D HALL", "D E STUNTZ"], :all_years=>[1972], :genus=>{:string=>"Hydnellum", :normalized=>"HYDNELLUM", :phonetized=>"HIDNILIM", :authors=>[], :years=>[], :normalized_authors=>[]}, :species=>{:string=>"scrobiculatum", :normalized=>"SCROBICULATUM", :phonetized=>"SCRABICILATA", :authors=>[], :years=>[], :normalized_authors=>[]}, :infraspecies=>[{:string=>"zonatum", :normalized=>"ZONATUM", :phonetized=>"ZANATA", :authors=>["Banker", "D. Hall", "D.E. Stuntz"], :years=>[1972], :normalized_authors=>["BANKER", "D HALL", "D E STUNTZ"]}]}
20
+ end
21
+
22
+ it 'should normalize years to integers' do
23
+ future_year = Time.now.year + 10
24
+ @parser.parse("Hydnellum scrobiculatum Kern #{future_year} zonatum (Banker) D. Hall et D.E. Stuntz 1972?").should == {:all_authors=>["KERN", "BANKER", "D HALL", "D E STUNTZ"], :all_years=>[1972], :genus=>{:string=>"Hydnellum", :normalized=>"HYDNELLUM", :phonetized=>"HIDNILIM", :authors=>[], :years=>[], :normalized_authors=>[]}, :species=>{:string=>"scrobiculatum", :normalized=>"SCROBICULATUM", :phonetized=>"SCRABICILATA", :authors=>["Kern"], :years=>[], :normalized_authors=>["KERN"]}, :infraspecies=>[{:string=>"zonatum", :normalized=>"ZONATUM", :phonetized=>"ZANATA", :authors=>["Banker", "D. Hall", "D.E. Stuntz"], :years=>[1972], :normalized_authors=>["BANKER", "D HALL", "D E STUNTZ"]}]}
20
25
  end
21
26
  end
22
27
 
@@ -8,7 +8,7 @@
8
8
  Pomatomus|Pomatomas|true|1
9
9
  Pomatomus L.|Pomatomas Linn.|true|1
10
10
  Pomatomus Ber|Pomatomas Linn|false|1
11
- Pomatomus L. 1753|Pomatomus Linn. 1800|false|0
11
+ Pomatomus L. 1758|Pomatomus Linn. 1800|false|0
12
12
  Patella|Abbella|false|3
13
13
 
14
14
  ## additional authorship should match
@@ -37,8 +37,8 @@ Pomatomus saltator (Linnaeus, 1766)|Pomatomus saltatrix (Linnaeus, 1766)|true|0|
37
37
  #
38
38
  #Trinomial names
39
39
  Homo sapiens stupidus|Homo spiens stupidus|true|1
40
- Pomatomus saltator saltator L. 1753|Pomatomus saltator var. saltatror L. 1753|true|1
41
- Pomatomus saltator L. 1753|Pomatomus saltator var. saltatror L. 1753|false|5
40
+ Pomatomus saltator saltator L. 1758|Pomatomus saltator var. saltatror L. 1758|true|1
41
+ Pomatomus saltator L. 1758|Pomatomus saltator var. saltatror L. 1758|false|5
42
42
  Pomatomus saltator saltator saltatorische|Pomatomus saltator soltator|true|1
43
43
 
44
44
 
data/taxamatch_rb.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "taxamatch_rb"
8
- s.version = "0.8.4"
8
+ s.version = "0.8.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dmitry Mozzherin"]
12
- s.date = "2012-02-13"
12
+ s.date = "2012-02-22"
13
13
  s.description = "This gem implements algorithm for fuzzy matching scientific names developed by Tony Rees"
14
14
  s.email = "dmozzherin@eol.org"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taxamatch_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-13 00:00:00.000000000Z
12
+ date: 2012-02-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: biodiversity19
16
- requirement: &70328583642780 !ruby/object:Gem::Requirement
16
+ requirement: &70273147270940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.10
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70328583642780
24
+ version_requirements: *70273147270940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: damerau-levenshtein
27
- requirement: &70328583642180 !ruby/object:Gem::Requirement
27
+ requirement: &70273147270340 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.5.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70328583642180
35
+ version_requirements: *70273147270340
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake-compiler
38
- requirement: &70328583629080 !ruby/object:Gem::Requirement
38
+ requirement: &70273147269760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70328583629080
46
+ version_requirements: *70273147269760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70328583628480 !ruby/object:Gem::Requirement
49
+ requirement: &70273147269160 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.3.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70328583628480
57
+ version_requirements: *70273147269160
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cucumber
60
- requirement: &70328583627880 !ruby/object:Gem::Requirement
60
+ requirement: &70273147268580 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70328583627880
68
+ version_requirements: *70273147268580
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70328583627280 !ruby/object:Gem::Requirement
71
+ requirement: &70273147267980 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70328583627280
79
+ version_requirements: *70273147267980
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70328583626700 !ruby/object:Gem::Requirement
82
+ requirement: &70273147267380 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.6.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70328583626700
90
+ version_requirements: *70273147267380
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rcov
93
- requirement: &70328583626100 !ruby/object:Gem::Requirement
93
+ requirement: &70273147266800 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70328583626100
101
+ version_requirements: *70273147266800
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: ruby-debug19
104
- requirement: &70328583625500 !ruby/object:Gem::Requirement
104
+ requirement: &70273147259780 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70328583625500
112
+ version_requirements: *70273147259780
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: ruby-prof
115
- requirement: &70328583624960 !ruby/object:Gem::Requirement
115
+ requirement: &70273147259200 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70328583624960
123
+ version_requirements: *70273147259200
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: shoulda
126
- requirement: &70328583624380 !ruby/object:Gem::Requirement
126
+ requirement: &70273147258620 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70328583624380
134
+ version_requirements: *70273147258620
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: mocha
137
- requirement: &70328583623720 !ruby/object:Gem::Requirement
137
+ requirement: &70273147258080 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,7 +142,7 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70328583623720
145
+ version_requirements: *70273147258080
146
146
  description: This gem implements algorithm for fuzzy matching scientific names developed
147
147
  by Tony Rees
148
148
  email: dmozzherin@eol.org
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  segments:
185
185
  - 0
186
- hash: 1595435064862339145
186
+ hash: -2248869889461974238
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  none: false
189
189
  requirements: