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
- #words_end ⇒ Object
- #words_start ⇒ Object
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
| 64 65 66 | # File 'lib/vendor/gnfinder/name.rb', line 64 def best_match_type best_result&.match_type end | 
#best_result ⇒ Object
Verification helpers
| 52 53 54 | # File 'lib/vendor/gnfinder/name.rb', line 52 def best_result found.verification.best_result if is_verified? end | 
#classification_path ⇒ Object
| 43 44 45 | # File 'lib/vendor/gnfinder/name.rb', line 43 def classification_path found&.verification&.best_result&.classification_path&.split('|') || [] end | 
#classification_rank ⇒ Object
| 47 48 49 | # File 'lib/vendor/gnfinder/name.rb', line 47 def classification_rank found&.verification&.best_result&.classification_ranks&.split('|') || [] end | 
#is_in_taxonworks? ⇒ Boolean
| 88 89 90 | # File 'lib/vendor/gnfinder/name.rb', line 88 def is_in_taxonworks? matches.any? end | 
#is_low_probability? ⇒ Boolean
| 60 61 62 | # File 'lib/vendor/gnfinder/name.rb', line 60 def is_low_probability? log_odds < LOW_PROBABILITY end | 
#is_new_name? ⇒ Boolean
| 74 75 76 | # File 'lib/vendor/gnfinder/name.rb', line 74 def is_new_name? %w{SP_NOV COMB_NOV SUBSP_NOV}.include?(found.annotation_nomen_type) end | 
#is_verified? ⇒ Boolean
| 56 57 58 | # File 'lib/vendor/gnfinder/name.rb', line 56 def is_verified? [nil, 'NoMatch'].exclude?(found.verification.best_result&.match_type) end | 
#log_odds ⇒ Object
Generic helpers
| 70 71 72 | # File 'lib/vendor/gnfinder/name.rb', line 70 def log_odds found.odds_log10 end | 
#matches ⇒ Object
Returns Array of TaxonName.
| 83 84 85 86 | # File 'lib/vendor/gnfinder/name.rb', line 83 def matches TaxonName.where(project_id:, cached: found.name) .or( TaxonName.where(project_id:, cached_original_combination: found.name)) end | 
#protonym_name ⇒ Object
| 78 79 80 | # File 'lib/vendor/gnfinder/name.rb', line 78 def protonym_name found.name.split(' ').last end | 
#taxonworks_parent ⇒ Object
| 102 103 104 105 106 107 | # File 'lib/vendor/gnfinder/name.rb', line 102 def taxonworks_parent return nil unless taxonworks_parent_name TaxonName.find_by( name: taxonworks_parent_name, project_id:) end | 
#taxonworks_parent_name ⇒ Object
| 92 93 94 95 96 97 98 99 100 | # File 'lib/vendor/gnfinder/name.rb', line 92 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
| 39 40 41 | # File 'lib/vendor/gnfinder/name.rb', line 39 def words_after found.words_after || [] end | 
#words_before ⇒ Object
| 35 36 37 | # File 'lib/vendor/gnfinder/name.rb', line 35 def words_before found.words_before || [] end | 
#words_end ⇒ Object
| 31 32 33 | # File 'lib/vendor/gnfinder/name.rb', line 31 def words_end found.end end | 
#words_start ⇒ Object
| 27 28 29 | # File 'lib/vendor/gnfinder/name.rb', line 27 def words_start found.start end |