mindee 3.11.0 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +27 -0
  4. data/README.md +23 -23
  5. data/Rakefile +5 -0
  6. data/bin/mindee.rb +7 -1
  7. data/docs/bank_account_details_v2.md +5 -1
  8. data/docs/bank_check_v1.md +6 -2
  9. data/docs/bank_statement_fr_v1.md +3 -0
  10. data/docs/barcode_reader_v1.md +5 -1
  11. data/docs/bill_of_lading_v1.md +202 -0
  12. data/docs/carte_grise_v1.md +5 -1
  13. data/docs/carte_vitale_v1.md +5 -1
  14. data/docs/code_samples/bill_of_lading_v1_async.txt +19 -0
  15. data/docs/code_samples/energy_bill_fra_v1_async.txt +19 -0
  16. data/docs/code_samples/financial_document_v1_async.txt +19 -0
  17. data/docs/code_samples/invoices_v4_async.txt +19 -0
  18. data/docs/code_samples/nutrition_facts_v1_async.txt +19 -0
  19. data/docs/code_samples/payslip_fra_v2_async.txt +19 -0
  20. data/docs/code_samples/us_healthcare_cards_v1_async.txt +19 -0
  21. data/docs/cropper_v1.md +6 -2
  22. data/docs/custom_v1.md +5 -3
  23. data/docs/energy_bill_fra_v1.md +249 -0
  24. data/docs/eu_driver_license_v1.md +6 -2
  25. data/docs/expense_receipts_v5.md +38 -11
  26. data/docs/financial_document_v1.md +80 -23
  27. data/docs/generated_v1.md +3 -0
  28. data/docs/getting_started.md +3 -0
  29. data/docs/idcard_fr_v2.md +15 -2
  30. data/docs/international_id_v2.md +13 -1
  31. data/docs/invoice_splitter_v1.md +16 -13
  32. data/docs/invoices_v4.md +57 -23
  33. data/docs/license_plates_v1.md +5 -1
  34. data/docs/multi_receipts_detector_v1.md +5 -1
  35. data/docs/nutrition_facts_v1.md +295 -0
  36. data/docs/passport_v1.md +5 -1
  37. data/docs/payslip_fra_v2.md +218 -0
  38. data/docs/proof_of_address_v1.md +5 -1
  39. data/docs/resume_v1.md +24 -1
  40. data/docs/us_driver_license_v1.md +6 -2
  41. data/docs/us_healthcare_cards_v1.md +208 -0
  42. data/docs/us_mail_v2.md +5 -1
  43. data/docs/us_w9_v1.md +6 -2
  44. data/examples/auto_invoice_splitter_extraction.rb +43 -0
  45. data/lib/mindee/client.rb +20 -8
  46. data/lib/mindee/extraction/common/extracted_image.rb +73 -0
  47. data/lib/mindee/extraction/common/image_extractor.rb +189 -0
  48. data/lib/mindee/extraction/common.rb +4 -0
  49. data/lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb +26 -0
  50. data/lib/mindee/extraction/multi_receipts_extractor.rb +3 -0
  51. data/lib/mindee/extraction/pdf_extractor/extracted_pdf.rb +55 -0
  52. data/lib/mindee/extraction/pdf_extractor/pdf_extractor.rb +111 -0
  53. data/lib/mindee/extraction/pdf_extractor.rb +4 -0
  54. data/lib/mindee/extraction/tax_extractor/tax_extractor.rb +322 -0
  55. data/lib/mindee/extraction/tax_extractor.rb +1 -320
  56. data/lib/mindee/extraction.rb +3 -0
  57. data/lib/mindee/http/endpoint.rb +18 -6
  58. data/lib/mindee/input/sources.rb +8 -0
  59. data/lib/mindee/parsing/common/api_response.rb +1 -1
  60. data/lib/mindee/parsing/common/document.rb +31 -1
  61. data/lib/mindee/parsing/common/extras/cropper_extra.rb +29 -0
  62. data/lib/mindee/parsing/common/extras/extras.rb +50 -0
  63. data/lib/mindee/parsing/common/extras/full_text_ocr_extra.rb +32 -0
  64. data/lib/mindee/parsing/common/extras.rb +5 -0
  65. data/lib/mindee/parsing/common/page.rb +5 -0
  66. data/lib/mindee/parsing/standard/base_field.rb +1 -0
  67. data/lib/mindee/parsing/standard/company_registration_field.rb +17 -0
  68. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1.rb +39 -0
  69. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rb +52 -0
  70. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb +95 -0
  71. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rb +58 -0
  72. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_document.rb +136 -0
  73. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rb +58 -0
  74. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_page.rb +32 -0
  75. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rb +58 -0
  76. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +3 -1
  77. data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +22 -1
  78. data/lib/mindee/product/financial_document/financial_document_v1_page.rb +1 -1
  79. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +4 -15
  80. data/lib/mindee/product/fr/energy_bill/energy_bill_v1.rb +41 -0
  81. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +235 -0
  82. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rb +48 -0
  83. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rb +48 -0
  84. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +97 -0
  85. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +54 -0
  86. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +34 -0
  87. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb +97 -0
  88. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rb +97 -0
  89. data/lib/mindee/product/fr/payslip/payslip_v2.rb +41 -0
  90. data/lib/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rb +54 -0
  91. data/lib/mindee/product/fr/payslip/payslip_v2_document.rb +128 -0
  92. data/lib/mindee/product/fr/payslip/payslip_v2_employee.rb +78 -0
  93. data/lib/mindee/product/fr/payslip/payslip_v2_employer.rb +78 -0
  94. data/lib/mindee/product/fr/payslip/payslip_v2_employment.rb +72 -0
  95. data/lib/mindee/product/fr/payslip/payslip_v2_page.rb +34 -0
  96. data/lib/mindee/product/fr/payslip/payslip_v2_pay_detail.rb +100 -0
  97. data/lib/mindee/product/fr/payslip/payslip_v2_pay_period.rb +66 -0
  98. data/lib/mindee/product/fr/payslip/payslip_v2_pto.rb +56 -0
  99. data/lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb +81 -0
  100. data/lib/mindee/product/international_id/international_id_v2_document.rb +1 -1
  101. data/lib/mindee/product/international_id/international_id_v2_page.rb +1 -1
  102. data/lib/mindee/product/invoice/invoice_v4_document.rb +3 -1
  103. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +22 -1
  104. data/lib/mindee/product/invoice/invoice_v4_page.rb +1 -1
  105. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +1 -1
  106. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +1 -1
  107. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +1 -1
  108. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rb +39 -0
  109. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rb +52 -0
  110. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rb +52 -0
  111. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb +52 -0
  112. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rb +52 -0
  113. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rb +173 -0
  114. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rb +87 -0
  115. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rb +32 -0
  116. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rb +52 -0
  117. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rb +52 -0
  118. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb +46 -0
  119. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb +58 -0
  120. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rb +52 -0
  121. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb +52 -0
  122. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rb +52 -0
  123. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rb +52 -0
  124. data/lib/mindee/product/receipt/receipt_v5_document.rb +1 -1
  125. data/lib/mindee/product/receipt/receipt_v5_line_item.rb +11 -1
  126. data/lib/mindee/product/receipt/receipt_v5_page.rb +1 -1
  127. data/lib/mindee/product/resume/resume_v1_certificate.rb +11 -1
  128. data/lib/mindee/product/resume/resume_v1_education.rb +14 -1
  129. data/lib/mindee/product/resume/resume_v1_language.rb +9 -1
  130. data/lib/mindee/product/resume/resume_v1_professional_experience.rb +15 -1
  131. data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +9 -1
  132. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1.rb +41 -0
  133. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +65 -0
  134. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +127 -0
  135. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +34 -0
  136. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +14 -1
  137. data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +5 -17
  138. data/lib/mindee/product.rb +6 -1
  139. data/lib/mindee/version.rb +1 -1
  140. data/mindee.gemspec +1 -0
  141. metadata +91 -3
  142. /data/lib/mindee/extraction/{ocr_extractor.rb → tax_extractor/ocr_extractor.rb} +0 -0
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module Payslip
9
+ # Information about the pay period.
10
+ class PayslipV2PayPeriod < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The end date of the pay period.
13
+ # @return [String]
14
+ attr_reader :end_date
15
+ # The month of the pay period.
16
+ # @return [String]
17
+ attr_reader :month
18
+ # The date of payment for the pay period.
19
+ # @return [String]
20
+ attr_reader :payment_date
21
+ # The start date of the pay period.
22
+ # @return [String]
23
+ attr_reader :start_date
24
+ # The year of the pay period.
25
+ # @return [String]
26
+ attr_reader :year
27
+
28
+ # @param prediction [Hash]
29
+ # @param page_id [Integer, nil]
30
+ def initialize(prediction, page_id)
31
+ super(prediction, page_id)
32
+ @end_date = prediction['end_date']
33
+ @month = prediction['month']
34
+ @payment_date = prediction['payment_date']
35
+ @start_date = prediction['start_date']
36
+ @year = prediction['year']
37
+ @page_id = page_id
38
+ end
39
+
40
+ # @return [Hash]
41
+ def printable_values
42
+ printable = {}
43
+ printable[:end_date] = format_for_display(@end_date)
44
+ printable[:month] = format_for_display(@month)
45
+ printable[:payment_date] = format_for_display(@payment_date)
46
+ printable[:start_date] = format_for_display(@start_date)
47
+ printable[:year] = format_for_display(@year)
48
+ printable
49
+ end
50
+
51
+ # @return [String]
52
+ def to_s
53
+ printable = printable_values
54
+ out_str = String.new
55
+ out_str << "\n :End Date: #{printable[:end_date]}"
56
+ out_str << "\n :Month: #{printable[:month]}"
57
+ out_str << "\n :Payment Date: #{printable[:payment_date]}"
58
+ out_str << "\n :Start Date: #{printable[:start_date]}"
59
+ out_str << "\n :Year: #{printable[:year]}"
60
+ out_str
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module Payslip
9
+ # Information about paid time off.
10
+ class PayslipV2Pto < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The amount of paid time off accrued in this period.
13
+ # @return [Float]
14
+ attr_reader :accrued_this_period
15
+ # The balance of paid time off at the end of the period.
16
+ # @return [Float]
17
+ attr_reader :balance_end_of_period
18
+ # The amount of paid time off used in this period.
19
+ # @return [Float]
20
+ attr_reader :used_this_period
21
+
22
+ # @param prediction [Hash]
23
+ # @param page_id [Integer, nil]
24
+ def initialize(prediction, page_id)
25
+ super(prediction, page_id)
26
+ @accrued_this_period = prediction['accrued_this_period']
27
+ @balance_end_of_period = prediction['balance_end_of_period']
28
+ @used_this_period = prediction['used_this_period']
29
+ @page_id = page_id
30
+ end
31
+
32
+ # @return [Hash]
33
+ def printable_values
34
+ printable = {}
35
+ printable[:accrued_this_period] =
36
+ @accrued_this_period.nil? ? '' : Field.float_to_string(@accrued_this_period)
37
+ printable[:balance_end_of_period] =
38
+ @balance_end_of_period.nil? ? '' : Field.float_to_string(@balance_end_of_period)
39
+ printable[:used_this_period] = @used_this_period.nil? ? '' : Field.float_to_string(@used_this_period)
40
+ printable
41
+ end
42
+
43
+ # @return [String]
44
+ def to_s
45
+ printable = printable_values
46
+ out_str = String.new
47
+ out_str << "\n :Accrued This Period: #{printable[:accrued_this_period]}"
48
+ out_str << "\n :Balance End of Period: #{printable[:balance_end_of_period]}"
49
+ out_str << "\n :Used This Period: #{printable[:used_this_period]}"
50
+ out_str
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module FR
8
+ module Payslip
9
+ # Detailed information about the earnings.
10
+ class PayslipV2SalaryDetail < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The amount of the earnings.
13
+ # @return [Float]
14
+ attr_reader :amount
15
+ # The base value of the earnings.
16
+ # @return [Float]
17
+ attr_reader :base
18
+ # The description of the earnings.
19
+ # @return [String]
20
+ attr_reader :description
21
+ # The rate of the earnings.
22
+ # @return [Float]
23
+ attr_reader :rate
24
+
25
+ # @param prediction [Hash]
26
+ # @param page_id [Integer, nil]
27
+ def initialize(prediction, page_id)
28
+ super(prediction, page_id)
29
+ @amount = prediction['amount']
30
+ @base = prediction['base']
31
+ @description = prediction['description']
32
+ @rate = prediction['rate']
33
+ @page_id = page_id
34
+ end
35
+
36
+ # @return [Hash]
37
+ def printable_values
38
+ printable = {}
39
+ printable[:amount] = @amount.nil? ? '' : Field.float_to_string(@amount)
40
+ printable[:base] = @base.nil? ? '' : Field.float_to_string(@base)
41
+ printable[:description] = format_for_display(@description)
42
+ printable[:rate] = @rate.nil? ? '' : Field.float_to_string(@rate)
43
+ printable
44
+ end
45
+
46
+ # @return [Hash]
47
+ def table_printable_values
48
+ printable = {}
49
+ printable[:amount] = @amount.nil? ? '' : Field.float_to_string(@amount)
50
+ printable[:base] = @base.nil? ? '' : Field.float_to_string(@base)
51
+ printable[:description] = format_for_display(@description, 36)
52
+ printable[:rate] = @rate.nil? ? '' : Field.float_to_string(@rate)
53
+ printable
54
+ end
55
+
56
+ # @return [String]
57
+ def to_table_line
58
+ printable = table_printable_values
59
+ out_str = String.new
60
+ out_str << format('| %- 13s', printable[:amount])
61
+ out_str << format('| %- 10s', printable[:base])
62
+ out_str << format('| %- 37s', printable[:description])
63
+ out_str << format('| %- 10s', printable[:rate])
64
+ out_str << '|'
65
+ end
66
+
67
+ # @return [String]
68
+ def to_s
69
+ printable = printable_values
70
+ out_str = String.new
71
+ out_str << "\n :Amount: #{printable[:amount]}"
72
+ out_str << "\n :Base: #{printable[:base]}"
73
+ out_str << "\n :Description: #{printable[:description]}"
74
+ out_str << "\n :Rate: #{printable[:rate]}"
75
+ out_str
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -5,7 +5,7 @@ require_relative '../../parsing'
5
5
  module Mindee
6
6
  module Product
7
7
  module InternationalId
8
- # International ID API version 2.0 document data.
8
+ # International ID API version 2.1 document data.
9
9
  class InternationalIdV2Document < Mindee::Parsing::Common::Prediction
10
10
  include Mindee::Parsing::Standard
11
11
  # The physical address of the document holder.
@@ -6,7 +6,7 @@ require_relative 'international_id_v2_document'
6
6
  module Mindee
7
7
  module Product
8
8
  module InternationalId
9
- # International ID API version 2.0 page data.
9
+ # International ID API version 2.1 page data.
10
10
  class InternationalIdV2Page < Mindee::Parsing::Common::Page
11
11
  # @param prediction [Hash]
12
12
  def initialize(prediction)
@@ -6,7 +6,7 @@ require_relative 'invoice_v4_line_item'
6
6
  module Mindee
7
7
  module Product
8
8
  module Invoice
9
- # Invoice API version 4.6 document data.
9
+ # Invoice API version 4.7 document data.
10
10
  class InvoiceV4Document < Mindee::Parsing::Common::Prediction
11
11
  include Mindee::Parsing::Standard
12
12
  # The customer's address used for billing.
@@ -176,6 +176,7 @@ module Mindee
176
176
  out_str << "+#{char * 12}"
177
177
  out_str << "+#{char * 14}"
178
178
  out_str << "+#{char * 14}"
179
+ out_str << "+#{char * 17}"
179
180
  out_str << "+#{char * 12}"
180
181
  out_str << '+'
181
182
  out_str
@@ -195,6 +196,7 @@ module Mindee
195
196
  out_str << ' Tax Amount |'
196
197
  out_str << ' Tax Rate (%) |'
197
198
  out_str << ' Total Amount |'
199
+ out_str << ' Unit of measure |'
198
200
  out_str << ' Unit Price |'
199
201
  out_str << "\n#{line_items_separator('=')}"
200
202
  out_str << "\n #{line_items}"
@@ -26,6 +26,9 @@ module Mindee
26
26
  # The item total amount.
27
27
  # @return [Float]
28
28
  attr_reader :total_amount
29
+ # The item unit of measure.
30
+ # @return [String]
31
+ attr_reader :unit_measure
29
32
  # The item unit price.
30
33
  # @return [Float]
31
34
  attr_reader :unit_price
@@ -40,12 +43,27 @@ module Mindee
40
43
  @tax_amount = prediction['tax_amount']
41
44
  @tax_rate = prediction['tax_rate']
42
45
  @total_amount = prediction['total_amount']
46
+ @unit_measure = prediction['unit_measure']
43
47
  @unit_price = prediction['unit_price']
44
48
  @page_id = page_id
45
49
  end
46
50
 
47
51
  # @return [Hash]
48
52
  def printable_values
53
+ printable = {}
54
+ printable[:description] = format_for_display(@description)
55
+ printable[:product_code] = format_for_display(@product_code)
56
+ printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
57
+ printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount)
58
+ printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
59
+ printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
60
+ printable[:unit_measure] = format_for_display(@unit_measure)
61
+ printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
62
+ printable
63
+ end
64
+
65
+ # @return [Hash]
66
+ def table_printable_values
49
67
  printable = {}
50
68
  printable[:description] = format_for_display(@description, 36)
51
69
  printable[:product_code] = format_for_display(@product_code, nil)
@@ -53,13 +71,14 @@ module Mindee
53
71
  printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount)
54
72
  printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
55
73
  printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
74
+ printable[:unit_measure] = format_for_display(@unit_measure, nil)
56
75
  printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
57
76
  printable
58
77
  end
59
78
 
60
79
  # @return [String]
61
80
  def to_table_line
62
- printable = printable_values
81
+ printable = table_printable_values
63
82
  out_str = String.new
64
83
  out_str << format('| %- 37s', printable[:description])
65
84
  out_str << format('| %- 13s', printable[:product_code])
@@ -67,6 +86,7 @@ module Mindee
67
86
  out_str << format('| %- 11s', printable[:tax_amount])
68
87
  out_str << format('| %- 13s', printable[:tax_rate])
69
88
  out_str << format('| %- 13s', printable[:total_amount])
89
+ out_str << format('| %- 16s', printable[:unit_measure])
70
90
  out_str << format('| %- 11s', printable[:unit_price])
71
91
  out_str << '|'
72
92
  end
@@ -81,6 +101,7 @@ module Mindee
81
101
  out_str << "\n :Tax Amount: #{printable[:tax_amount]}"
82
102
  out_str << "\n :Tax Rate (%): #{printable[:tax_rate]}"
83
103
  out_str << "\n :Total Amount: #{printable[:total_amount]}"
104
+ out_str << "\n :Unit of measure: #{printable[:unit_measure]}"
84
105
  out_str << "\n :Unit Price: #{printable[:unit_price]}"
85
106
  out_str
86
107
  end
@@ -6,7 +6,7 @@ require_relative 'invoice_v4_document'
6
6
  module Mindee
7
7
  module Product
8
8
  module Invoice
9
- # Invoice API version 4.6 page data.
9
+ # Invoice API version 4.7 page data.
10
10
  class InvoiceV4Page < Mindee::Parsing::Common::Page
11
11
  # @param prediction [Hash]
12
12
  def initialize(prediction)
@@ -29,7 +29,7 @@ module Mindee
29
29
 
30
30
  # Invoice Splitter V1 document prediction.
31
31
  class InvoiceSplitterV1Document < Mindee::Parsing::Common::Prediction
32
- # @return[Array<Mindee::Product::InvoiceSplitterV1PageGroup>]
32
+ # @return[Array<Mindee::Product::InvoiceSplitter::InvoiceSplitterV1PageGroup>]
33
33
  attr_reader :invoice_page_groups
34
34
 
35
35
  # @param prediction [Hash]
@@ -5,7 +5,7 @@ require_relative '../../parsing'
5
5
  module Mindee
6
6
  module Product
7
7
  module MultiReceiptsDetector
8
- # Multi Receipts Detector API version 1.0 document data.
8
+ # Multi Receipts Detector API version 1.1 document data.
9
9
  class MultiReceiptsDetectorV1Document < Mindee::Parsing::Common::Prediction
10
10
  include Mindee::Parsing::Standard
11
11
  # Positions of the receipts on the document.
@@ -6,7 +6,7 @@ require_relative 'multi_receipts_detector_v1_document'
6
6
  module Mindee
7
7
  module Product
8
8
  module MultiReceiptsDetector
9
- # Multi Receipts Detector API version 1.0 page data.
9
+ # Multi Receipts Detector API version 1.1 page data.
10
10
  class MultiReceiptsDetectorV1Page < Mindee::Parsing::Common::Page
11
11
  # @param prediction [Hash]
12
12
  def initialize(prediction)
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'nutrition_facts_label_v1_document'
5
+ require_relative 'nutrition_facts_label_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ # Nutrition Facts Label module.
10
+ module NutritionFactsLabel
11
+ # Nutrition Facts Label API version 1 inference prediction.
12
+ class NutritionFactsLabelV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'nutrition_facts'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = NutritionFactsLabelV1Document.new(prediction['prediction'], nil)
20
+ @pages = []
21
+ prediction['pages'].each do |page|
22
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
23
+ @pages.push(NutritionFactsLabelV1Page.new(page))
24
+ end
25
+ end
26
+ end
27
+
28
+ class << self
29
+ # Name of the endpoint for this product.
30
+ # @return [String]
31
+ attr_reader :endpoint_name
32
+ # Version for this product.
33
+ # @return [String]
34
+ attr_reader :endpoint_version
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module NutritionFactsLabel
8
+ # The amount of added sugars in the product.
9
+ class NutritionFactsLabelV1AddedSugar < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # DVs are the recommended amounts of added sugars to consume or not to exceed each day.
12
+ # @return [Float]
13
+ attr_reader :daily_value
14
+ # The amount of added sugars per 100g of the product.
15
+ # @return [Float]
16
+ attr_reader :per_100g
17
+ # The amount of added sugars per serving of the product.
18
+ # @return [Float]
19
+ attr_reader :per_serving
20
+
21
+ # @param prediction [Hash]
22
+ # @param page_id [Integer, nil]
23
+ def initialize(prediction, page_id)
24
+ super(prediction, page_id)
25
+ @daily_value = prediction['daily_value']
26
+ @per_100g = prediction['per_100g']
27
+ @per_serving = prediction['per_serving']
28
+ @page_id = page_id
29
+ end
30
+
31
+ # @return [Hash]
32
+ def printable_values
33
+ printable = {}
34
+ printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
35
+ printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
36
+ printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
37
+ printable
38
+ end
39
+
40
+ # @return [String]
41
+ def to_s
42
+ printable = printable_values
43
+ out_str = String.new
44
+ out_str << "\n :Daily Value: #{printable[:daily_value]}"
45
+ out_str << "\n :Per 100g: #{printable[:per_100g]}"
46
+ out_str << "\n :Per Serving: #{printable[:per_serving]}"
47
+ out_str
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module NutritionFactsLabel
8
+ # The amount of calories in the product.
9
+ class NutritionFactsLabelV1Calorie < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # DVs are the recommended amounts of calories to consume or not to exceed each day.
12
+ # @return [Float]
13
+ attr_reader :daily_value
14
+ # The amount of calories per 100g of the product.
15
+ # @return [Float]
16
+ attr_reader :per_100g
17
+ # The amount of calories per serving of the product.
18
+ # @return [Float]
19
+ attr_reader :per_serving
20
+
21
+ # @param prediction [Hash]
22
+ # @param page_id [Integer, nil]
23
+ def initialize(prediction, page_id)
24
+ super(prediction, page_id)
25
+ @daily_value = prediction['daily_value']
26
+ @per_100g = prediction['per_100g']
27
+ @per_serving = prediction['per_serving']
28
+ @page_id = page_id
29
+ end
30
+
31
+ # @return [Hash]
32
+ def printable_values
33
+ printable = {}
34
+ printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
35
+ printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
36
+ printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
37
+ printable
38
+ end
39
+
40
+ # @return [String]
41
+ def to_s
42
+ printable = printable_values
43
+ out_str = String.new
44
+ out_str << "\n :Daily Value: #{printable[:daily_value]}"
45
+ out_str << "\n :Per 100g: #{printable[:per_100g]}"
46
+ out_str << "\n :Per Serving: #{printable[:per_serving]}"
47
+ out_str
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module NutritionFactsLabel
8
+ # The amount of cholesterol in the product.
9
+ class NutritionFactsLabelV1Cholesterol < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # DVs are the recommended amounts of cholesterol to consume or not to exceed each day.
12
+ # @return [Float]
13
+ attr_reader :daily_value
14
+ # The amount of cholesterol per 100g of the product.
15
+ # @return [Float]
16
+ attr_reader :per_100g
17
+ # The amount of cholesterol per serving of the product.
18
+ # @return [Float]
19
+ attr_reader :per_serving
20
+
21
+ # @param prediction [Hash]
22
+ # @param page_id [Integer, nil]
23
+ def initialize(prediction, page_id)
24
+ super(prediction, page_id)
25
+ @daily_value = prediction['daily_value']
26
+ @per_100g = prediction['per_100g']
27
+ @per_serving = prediction['per_serving']
28
+ @page_id = page_id
29
+ end
30
+
31
+ # @return [Hash]
32
+ def printable_values
33
+ printable = {}
34
+ printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
35
+ printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
36
+ printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
37
+ printable
38
+ end
39
+
40
+ # @return [String]
41
+ def to_s
42
+ printable = printable_values
43
+ out_str = String.new
44
+ out_str << "\n :Daily Value: #{printable[:daily_value]}"
45
+ out_str << "\n :Per 100g: #{printable[:per_100g]}"
46
+ out_str << "\n :Per Serving: #{printable[:per_serving]}"
47
+ out_str
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module NutritionFactsLabel
8
+ # The amount of dietary fiber in the product.
9
+ class NutritionFactsLabelV1DietaryFiber < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # DVs are the recommended amounts of dietary fiber to consume or not to exceed each day.
12
+ # @return [Float]
13
+ attr_reader :daily_value
14
+ # The amount of dietary fiber per 100g of the product.
15
+ # @return [Float]
16
+ attr_reader :per_100g
17
+ # The amount of dietary fiber per serving of the product.
18
+ # @return [Float]
19
+ attr_reader :per_serving
20
+
21
+ # @param prediction [Hash]
22
+ # @param page_id [Integer, nil]
23
+ def initialize(prediction, page_id)
24
+ super(prediction, page_id)
25
+ @daily_value = prediction['daily_value']
26
+ @per_100g = prediction['per_100g']
27
+ @per_serving = prediction['per_serving']
28
+ @page_id = page_id
29
+ end
30
+
31
+ # @return [Hash]
32
+ def printable_values
33
+ printable = {}
34
+ printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
35
+ printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
36
+ printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
37
+ printable
38
+ end
39
+
40
+ # @return [String]
41
+ def to_s
42
+ printable = printable_values
43
+ out_str = String.new
44
+ out_str << "\n :Daily Value: #{printable[:daily_value]}"
45
+ out_str << "\n :Per 100g: #{printable[:per_100g]}"
46
+ out_str << "\n :Per Serving: #{printable[:per_serving]}"
47
+ out_str
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end