Class: Vendor::Gnfinder::Name
- Inherits:
-
Object
- Object
- Vendor::Gnfinder::Name
- Defined in:
- lib/vendor/gnfinder/name.rb
Overview
A loose wrapper for github.com/GlobalNamesArchitecture/gnfinder/blob/master/lib/protob_pb.rb
Constant Summary collapse
- LOW_PROBABILITY =
A hack at present, balance versus language and ongoing. For now, anything negative probability seems unlikely.
3.0
Instance Attribute Summary collapse
-
#found ⇒ Object
Alias for Name.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
Instance Method Summary collapse
- #best_match_type ⇒ Object
-
#best_result ⇒ Object
Verification helpers.
- #classification_path ⇒ Object
- #classification_rank ⇒ Object
-
#initialize(found_name, project_id = []) ⇒ Name
constructor
params found_name [Gnfinder name].
- #is_in_taxonworks? ⇒ Boolean
- #is_low_probability? ⇒ Boolean
- #is_new_name? ⇒ Boolean
- #is_verified? ⇒ Boolean
-
#log_odds ⇒ Object
Generic helpers.
-
#matches ⇒ Object
Array of TaxonName.
- #protonym_name ⇒ Object
- #taxonworks_parent ⇒ Object
- #taxonworks_parent_name ⇒ Object
- #words_after ⇒ Object
-
#words_before ⇒ Object
Name helpers.
Constructor Details
#initialize(found_name, project_id = []) ⇒ Name
params found_name [Gnfinder name]
17 18 19 20 |
# File 'lib/vendor/gnfinder/name.rb', line 17 def initialize(found_name, project_id = []) @project_id = project_id @found = found_name end |
Instance Attribute Details
#found ⇒ Object
Alias for Name
14 15 16 |
# File 'lib/vendor/gnfinder/name.rb', line 14 def found @found end |
#project_id ⇒ Object
Returns the value of attribute project_id.
11 12 13 |
# File 'lib/vendor/gnfinder/name.rb', line 11 def project_id @project_id end |
Instance Method Details
#best_match_type ⇒ Object
52 53 54 |
# File 'lib/vendor/gnfinder/name.rb', line 52 def best_match_type best_result&.match_type end |
#best_result ⇒ Object
Verification helpers
40 41 42 |
# File 'lib/vendor/gnfinder/name.rb', line 40 def best_result found.verification.best_result if is_verified? end |
#classification_path ⇒ Object
31 32 33 |
# File 'lib/vendor/gnfinder/name.rb', line 31 def classification_path found&.verification&.best_result&.classification_path&.split('|') || [] end |
#classification_rank ⇒ Object
35 36 37 |
# File 'lib/vendor/gnfinder/name.rb', line 35 def classification_rank found&.verification&.best_result&.classification_rank&.split('|') || [] end |
#is_in_taxonworks? ⇒ Boolean
76 77 78 |
# File 'lib/vendor/gnfinder/name.rb', line 76 def is_in_taxonworks? matches.any? end |
#is_low_probability? ⇒ Boolean
48 49 50 |
# File 'lib/vendor/gnfinder/name.rb', line 48 def is_low_probability? log_odds < LOW_PROBABILITY end |
#is_new_name? ⇒ Boolean
62 63 64 |
# File 'lib/vendor/gnfinder/name.rb', line 62 def is_new_name? [:SP_NOV, :COMB_NOV, :SUBSP_NOV].include?(found.annot_nomen_type) end |
#is_verified? ⇒ Boolean
44 45 46 |
# File 'lib/vendor/gnfinder/name.rb', line 44 def is_verified? found.verification && found.verification.best_result.match_type != :NONE end |
#log_odds ⇒ Object
Generic helpers
58 59 60 |
# File 'lib/vendor/gnfinder/name.rb', line 58 def log_odds Math.log10(found.odds) end |
#matches ⇒ Object
Returns Array of TaxonName.
71 72 73 74 |
# File 'lib/vendor/gnfinder/name.rb', line 71 def matches TaxonName.where(project_id: project_id, cached: found.name) .or( TaxonName.where(project_id: project_id, cached_original_combination: found.name)) end |
#protonym_name ⇒ Object
66 67 68 |
# File 'lib/vendor/gnfinder/name.rb', line 66 def protonym_name found.name.split(' ').last end |
#taxonworks_parent ⇒ Object
90 91 92 93 94 95 |
# File 'lib/vendor/gnfinder/name.rb', line 90 def taxonworks_parent return nil unless taxonworks_parent_name TaxonName.find_by( name: taxonworks_parent_name, project_id: project_id) end |
#taxonworks_parent_name ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/vendor/gnfinder/name.rb', line 80 def taxonworks_parent_name case found.cardinality when 0 nil else # TODO: likely not right with sp. nov. found.name.split(' ')[-2] end end |
#words_after ⇒ Object
27 28 29 |
# File 'lib/vendor/gnfinder/name.rb', line 27 def words_after found.words_after || [] end |
#words_before ⇒ Object
Name helpers
23 24 25 |
# File 'lib/vendor/gnfinder/name.rb', line 23 def words_before found.words_before || [] end |