Class: Vendor::Gnfinder::Result
- Inherits:
-
Object
- Object
- Vendor::Gnfinder::Result
- Defined in:
- lib/vendor/gnfinder/result.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#names ⇒ Object
Returns the value of attribute names.
- #new_names ⇒ Hash
-
#project_id ⇒ Object
Returns the value of attribute project_id.
- #unique_names ⇒ Hash
Instance Method Summary collapse
- #build_names ⇒ Object private
- #found_all? ⇒ Boolean
- #found_names ⇒ Object
-
#initialize(_client, _project_id = []) ⇒ Result
constructor
A new instance of Result.
- #missing_low_probability_names ⇒ Object
- #missing_names ⇒ Object
- #missing_new_names ⇒ Object
- #missing_other_names ⇒ Object
- #ocr_failure ⇒ Object
- #probable_source_of_text ⇒ Object
- #score ⇒ Object
- #verified_names ⇒ Object
Constructor Details
#initialize(_client, _project_id = []) ⇒ Result
Returns a new instance of Result.
10 11 12 13 14 |
# File 'lib/vendor/gnfinder/result.rb', line 10 def initialize(_client, _project_id = []) @project_id = _project_id @client = _client @names = build_names end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/vendor/gnfinder/result.rb', line 6 def client @client end |
#names ⇒ Object
Returns the value of attribute names.
8 9 10 |
# File 'lib/vendor/gnfinder/result.rb', line 8 def names @names end |
#new_names ⇒ Hash
60 61 62 |
# File 'lib/vendor/gnfinder/result.rb', line 60 def new_names @new_names end |
#project_id ⇒ Object
Returns the value of attribute project_id.
5 6 7 |
# File 'lib/vendor/gnfinder/result.rb', line 5 def project_id @project_id end |
#unique_names ⇒ Hash
44 45 46 |
# File 'lib/vendor/gnfinder/result.rb', line 44 def unique_names @unique_names end |
Instance Method Details
#build_names ⇒ Object (private)
94 95 96 97 98 99 100 |
# File 'lib/vendor/gnfinder/result.rb', line 94 def build_names n = client.names.map{|n| Vendor::Gnfinder::Name.new(n, project_id) }.sort{|a,b| a.found.name <=> b.found.name} n ||= [] @names = n end |
#found_all? ⇒ Boolean
84 85 86 |
# File 'lib/vendor/gnfinder/result.rb', line 84 def found_all? missing_names.empty? end |
#found_names ⇒ Object
64 65 66 |
# File 'lib/vendor/gnfinder/result.rb', line 64 def found_names unique_names.select{|k, v| v.first.is_in_taxonworks? } end |
#missing_low_probability_names ⇒ Object
80 81 82 |
# File 'lib/vendor/gnfinder/result.rb', line 80 def missing_low_probability_names missing_names.select{|k, v| v.first.is_low_probability? } end |
#missing_names ⇒ Object
68 69 70 |
# File 'lib/vendor/gnfinder/result.rb', line 68 def missing_names unique_names.select{|k, v| !v.first.is_in_taxonworks? } end |
#missing_new_names ⇒ Object
72 73 74 |
# File 'lib/vendor/gnfinder/result.rb', line 72 def missing_new_names missing_names.select{|k, v| v.first.is_new_name? && !v.first.is_low_probability? } end |
#missing_other_names ⇒ Object
76 77 78 |
# File 'lib/vendor/gnfinder/result.rb', line 76 def missing_other_names missing_names.select{|k, v| !v.first.is_new_name? && !v.first.is_low_probability? } end |
#ocr_failure ⇒ Object
39 40 41 |
# File 'lib/vendor/gnfinder/result.rb', line 39 def ocr_failure client.names.length == 0 end |
#probable_source_of_text ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vendor/gnfinder/result.rb', line 22 def probable_source_of_text case score when 3..23 if client.language == 'eng' 'original text' else 'uncertain (language)' end else if client.language == 'eng' 'secondary OCR' else 'uncertain (language)' end end end |
#score ⇒ Object
16 17 18 19 20 |
# File 'lib/vendor/gnfinder/result.rb', line 16 def score t = unique_names.keys.count.to_f sum_odds = unique_names.values.inject(0){|sum, names| sum += names.first.log_odds} sum_odds / t end |
#verified_names ⇒ Object
88 89 90 |
# File 'lib/vendor/gnfinder/result.rb', line 88 def verified_names unique_names.select{|k, v| v.first.is_verified? } end |