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.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/mindee/extraction/tax_extractor/tax_extractor.rb', line 147 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) # a tax is considered found horizontally if it has a value, otherwise it is vertical 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 |