Class: Mindee::Extraction::TaxExtractor
- Inherits:
-
OcrExtractor
- Object
- OcrExtractor
- Mindee::Extraction::TaxExtractor
- Defined in:
- lib/mindee/extraction/tax_extractor/tax_extractor.rb
Overview
Tax extractor class
Class Method Summary collapse
-
.extract_custom_tax(ocr_result, tax_names, min_rate_percentage = 0, max_rate_percentage = 100) ⇒ Mindee::Parsing::Standard::TaxField?
Extracts a single custom type of tax.
Class Method Details
.extract_custom_tax(ocr_result, tax_names, min_rate_percentage = 0, max_rate_percentage = 100) ⇒ Mindee::Parsing::Standard::TaxField?
Extracts a single custom type of tax. For the sake of simplicity, this only extracts the first example, unless specifically instructed otherwise.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/mindee/extraction/tax_extractor/tax_extractor.rb', line 162 def self.extract_custom_tax(ocr_result, tax_names, min_rate_percentage = 0, max_rate_percentage = 100) return nil if ocr_result.is_a?(Mindee::Parsing::Common::Ocr) || tax_names.empty? tax_names.sort! found_hash = pick_best(extract_horizontal_tax(ocr_result, tax_names), tax_names) if found_hash.nil? || found_hash['value'].nil? found_hash = extract_vertical_tax(ocr_result, tax_names, found_hash) end found_hash = curate_values(found_hash, min_rate_percentage, max_rate_percentage) return if found_hash.nil? || found_hash.empty? create_tax_field(found_hash) end |