Class: Taxamatch::Atomizer
- Inherits:
-
Object
- Object
- Taxamatch::Atomizer
- Defined in:
- lib/taxamatch_rb/atomizer.rb
Instance Method Summary collapse
-
#initialize ⇒ Atomizer
constructor
A new instance of Atomizer.
- #organize_results(parsed_raw) ⇒ Object
- #parse(name) ⇒ Object
- #parsed_raw ⇒ Object
Constructor Details
#initialize ⇒ Atomizer
Returns a new instance of Atomizer.
7 8 9 10 11 |
# File 'lib/taxamatch_rb/atomizer.rb', line 7 def initialize @parser = ScientificNameParser.new @parsed_raw = nil @res = {} end |
Instance Method Details
#organize_results(parsed_raw) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/taxamatch_rb/atomizer.rb', line 22 def organize_results(parsed_raw) pr = parsed_raw return nil unless pr[:parsed] @res = {:all_authors => [], :all_years => []} d = pr[:details][0] @res[:canonical_form] = pr[:canonical] process_node(:uninomial, d[:uninomial]) process_node(:genus, d[:genus]) process_node(:species, d[:species], true) process_infraspecies(d[:infraspecies]) @res[:all_authors] = @res[:all_authors].uniq.map do |a| Taxamatch::Normalizer.normalize(a) end @res[:all_years].uniq! @res.keys.size > 2 ? @res : nil end |
#parse(name) ⇒ Object
13 14 15 16 |
# File 'lib/taxamatch_rb/atomizer.rb', line 13 def parse(name) @parsed_raw = @parser.parse(name)[:scientificName] organize_results(@parsed_raw) end |
#parsed_raw ⇒ Object
18 19 20 |
# File 'lib/taxamatch_rb/atomizer.rb', line 18 def parsed_raw return @parsed_raw end |