dimus-taxamatch_rb 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@ module Taxamatch
12
12
 
13
13
  def parse(name)
14
14
  @res = {:all_authors => [], :all_years => []}
15
- @parsed_raw = JSON.load(@parser.parse(name).to_json)['scientificName']
15
+ @parsed_raw = @parser.parse(name)[:scientificName]
16
16
  organize_results
17
17
  end
18
18
 
@@ -24,12 +24,12 @@ module Taxamatch
24
24
 
25
25
  def organize_results
26
26
  pr = @parsed_raw
27
- return nil unless pr['parsed']
28
- d = pr['details'][0]
29
- process_node(:uninomial, d['uninomial'])
30
- process_node(:genus, d['genus'])
31
- process_node(:species, d['species'], true)
32
- process_infraspecies(d['infraspecies'])
27
+ return nil unless pr[:parsed]
28
+ d = pr[:details][0]
29
+ process_node(:uninomial, d[:uninomial])
30
+ process_node(:genus, d[:genus])
31
+ process_node(:species, d[:species], true)
32
+ process_infraspecies(d[:infraspecies])
33
33
  @res[:all_authors] = @res[:all_authors].uniq.map {|a| Taxamatch::Normalizer.normalize(a)}
34
34
  @res[:all_years].uniq!
35
35
  @res.keys.size > 2 ? @res : nil
@@ -38,9 +38,9 @@ module Taxamatch
38
38
  def process_node(name, node, is_species = false)
39
39
  return unless node
40
40
  @res[name] = {}
41
- @res[name][:epitheton] = node['epitheton']
42
- @res[name][:normalized] = Taxamatch::Normalizer.normalize(node['epitheton'])
43
- @res[name][:phonetized] = Taxamatch::Phonetizer.near_match(node['epitheton'], is_species)
41
+ @res[name][:epitheton] = node[:epitheton]
42
+ @res[name][:normalized] = Taxamatch::Normalizer.normalize(node[:epitheton])
43
+ @res[name][:phonetized] = Taxamatch::Phonetizer.near_match(node[:epitheton], is_species)
44
44
  get_authors_years(node, @res[name])
45
45
  end
46
46
 
@@ -49,9 +49,9 @@ module Taxamatch
49
49
  @res[:infraspecies] = []
50
50
  node.each do |infr|
51
51
  hsh = {}
52
- hsh[:epitheton] = infr['epitheton']
53
- hsh[:normalized] = Taxamatch::Normalizer.normalize(infr['epitheton'])
54
- hsh[:phonetized] = Taxamatch::Phonetizer.near_match(infr['epitheton'], true)
52
+ hsh[:epitheton] = infr[:epitheton]
53
+ hsh[:normalized] = Taxamatch::Normalizer.normalize(infr[:epitheton])
54
+ hsh[:phonetized] = Taxamatch::Phonetizer.near_match(infr[:epitheton], true)
55
55
  get_authors_years(infr,hsh)
56
56
  @res[:infraspecies] << hsh
57
57
  end
@@ -60,13 +60,13 @@ module Taxamatch
60
60
  def get_authors_years(node, res)
61
61
  res[:authors] = []
62
62
  res[:years] = []
63
- ['basionymAuthorTeam','combinationAuthorTeam'].each do |au|
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']
67
- if node[au]['exAuthorTeam']
68
- res[:authors] += node[au]['exAuthorTeam']['author']
69
- res[:years] << node[au]['exAuthorTeam']['year'] if node[au]['exAuthorTeam']['year']
65
+ res[:authors] += node[au][:author]
66
+ res[:years] << node[au][:year] if node[au][:year]
67
+ if node[au][:exAuthorTeam]
68
+ res[:authors] += node[au][:exAuthorTeam][:author]
69
+ res[:years] << node[au][:exAuthorTeam][:year] if node[au][:exAuthorTeam][:year]
70
70
  end
71
71
  end
72
72
  end
@@ -80,9 +80,3 @@ module Taxamatch
80
80
  end
81
81
  end
82
82
 
83
- if __FILE__ == $0
84
- require 'pp'
85
- p = Parser.new
86
- puts p.parse('Salmonella werahensis (Castellani) Hauduroy and Ehringer in Hauduroy 1937')
87
- end
88
-
@@ -14,12 +14,13 @@ describe 'DamerauLevenshteinMod' do
14
14
  end
15
15
  end
16
16
 
17
- describe 'Parser' do
17
+ describe 'Atomizer' do
18
18
  before(:all) do
19
19
  @parser = Taxamatch::Atomizer.new
20
20
  end
21
21
 
22
22
  it 'should parse uninomials' do
23
+ @parser.parse
23
24
  @parser.parse('Betula').should == {:all_authors=>[], :all_years=>[], :uninomial=>{:epitheton=>"Betula", :normalized=>"BETULA", :phonetized=>"BITILA", :authors=>[], :years=>[], :normalized_authors=>[]}}
24
25
  @parser.parse('Ærenea Lacordaire, 1872').should == {:all_authors=>["LACORDAIRE"], :all_years=>["1872"], :uninomial=>{:epitheton=>"Aerenea", :normalized=>"AERENEA", :phonetized=>"ERINIA", :authors=>["Lacordaire"], :years=>["1872"], :normalized_authors=>["LACORDAIRE"]}}
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimus-taxamatch_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Mozzherin
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-16 00:00:00 -07:00
12
+ date: 2009-08-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: "0"
33
+ version: 0.5.13
34
34
  version:
35
35
  description: This gem implements algorithsm for fuzzy matching scientific names developed by Tony Rees
36
36
  email: dmozzherin@eol.org