mindee 2.2.0 → 3.0.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 (152) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +2 -0
  4. data/.yardopts +1 -0
  5. data/CHANGELOG.md +36 -0
  6. data/README.md +29 -16
  7. data/bin/mindee.rb +23 -26
  8. data/docs/code_samples/bank_account_details_v1.txt +10 -5
  9. data/docs/code_samples/bank_account_details_v2.txt +19 -0
  10. data/docs/code_samples/bank_check_v1.txt +10 -5
  11. data/docs/code_samples/carte_vitale_v1.txt +10 -5
  12. data/docs/code_samples/custom_v1.txt +19 -10
  13. data/docs/code_samples/default.txt +10 -2
  14. data/docs/code_samples/expense_receipts_v4.txt +10 -5
  15. data/docs/code_samples/expense_receipts_v5.txt +11 -6
  16. data/docs/code_samples/financial_document_v1.txt +10 -5
  17. data/docs/code_samples/idcard_fr_v1.txt +10 -5
  18. data/docs/code_samples/invoice_splitter_v1_async.txt +66 -0
  19. data/docs/code_samples/invoices_v4.txt +10 -5
  20. data/docs/code_samples/license_plates_v1.txt +10 -5
  21. data/docs/code_samples/passport_v1.txt +10 -5
  22. data/docs/code_samples/proof_of_address_v1.txt +10 -5
  23. data/docs/ruby-api-builder.md +30 -31
  24. data/docs/ruby-getting-started.md +64 -23
  25. data/docs/ruby-invoice-ocr.md +70 -59
  26. data/docs/ruby-passport-ocr.md +49 -40
  27. data/docs/ruby-receipt-ocr.md +45 -32
  28. data/lib/mindee/client.rb +150 -148
  29. data/lib/mindee/geometry/min_max.rb +23 -0
  30. data/lib/mindee/geometry/point.rb +35 -0
  31. data/lib/mindee/geometry/polygon.rb +23 -0
  32. data/lib/mindee/geometry/quadrilateral.rb +45 -0
  33. data/lib/mindee/geometry/utils.rb +81 -0
  34. data/lib/mindee/geometry.rb +5 -116
  35. data/lib/mindee/http/endpoint.rb +123 -16
  36. data/lib/mindee/http.rb +3 -0
  37. data/lib/mindee/input/sources.rb +87 -73
  38. data/lib/mindee/parsing/common/api_response.rb +109 -0
  39. data/lib/mindee/parsing/common/document.rb +48 -0
  40. data/lib/mindee/parsing/common/error.rb +24 -0
  41. data/lib/mindee/parsing/common/inference.rb +43 -0
  42. data/lib/mindee/parsing/common/ocr/mvision_v1.rb +34 -0
  43. data/lib/mindee/parsing/common/ocr/ocr.rb +169 -0
  44. data/lib/mindee/parsing/common/ocr.rb +3 -0
  45. data/lib/mindee/parsing/common/orientation.rb +26 -0
  46. data/lib/mindee/parsing/common/page.rb +40 -0
  47. data/lib/mindee/parsing/common/prediction.rb +15 -0
  48. data/lib/mindee/parsing/common/product.rb +19 -0
  49. data/lib/mindee/parsing/common.rb +10 -0
  50. data/lib/mindee/parsing/custom/classification_field.rb +28 -0
  51. data/lib/mindee/parsing/custom/list_field.rb +76 -0
  52. data/lib/mindee/parsing/custom.rb +4 -0
  53. data/lib/mindee/parsing/standard/amount_field.rb +26 -0
  54. data/lib/mindee/parsing/standard/base_field.rb +104 -0
  55. data/lib/mindee/parsing/standard/classification_field.rb +16 -0
  56. data/lib/mindee/parsing/standard/company_registration_field.rb +21 -0
  57. data/lib/mindee/parsing/standard/date_field.rb +34 -0
  58. data/lib/mindee/parsing/standard/locale_field.rb +50 -0
  59. data/lib/mindee/parsing/standard/payment_details_field.rb +42 -0
  60. data/lib/mindee/parsing/standard/position_field.rb +44 -0
  61. data/lib/mindee/parsing/standard/tax_field.rb +108 -0
  62. data/lib/mindee/parsing/standard/text_field.rb +16 -0
  63. data/lib/mindee/parsing/standard.rb +12 -0
  64. data/lib/mindee/parsing.rb +3 -2
  65. data/lib/mindee/{input → pdf}/pdf_processing.rb +4 -32
  66. data/lib/mindee/pdf/pdf_tools.rb +34 -0
  67. data/lib/mindee/pdf.rb +3 -0
  68. data/lib/mindee/product/.rubocop.yml +5 -0
  69. data/lib/mindee/product/custom/custom_v1.rb +35 -0
  70. data/lib/mindee/product/custom/custom_v1_document.rb +60 -0
  71. data/lib/mindee/product/custom/custom_v1_page.rb +32 -0
  72. data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +38 -0
  73. data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +37 -0
  74. data/lib/mindee/product/eu/license_plate/license_plate_v1_page.rb +34 -0
  75. data/lib/mindee/product/financial_document/financial_document_v1.rb +36 -0
  76. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +188 -0
  77. data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +90 -0
  78. data/lib/mindee/product/financial_document/financial_document_v1_page.rb +32 -0
  79. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +38 -0
  80. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +43 -0
  81. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_page.rb +34 -0
  82. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +38 -0
  83. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +71 -0
  84. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +58 -0
  85. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_page.rb +34 -0
  86. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +38 -0
  87. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_document.rb +52 -0
  88. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_page.rb +34 -0
  89. data/lib/mindee/product/fr/id_card/id_card_v1.rb +38 -0
  90. data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +82 -0
  91. data/lib/mindee/product/fr/id_card/id_card_v1_page.rb +48 -0
  92. data/lib/mindee/product/invoice/invoice_v4.rb +37 -0
  93. data/lib/mindee/product/invoice/invoice_v4_document.rb +212 -0
  94. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +66 -0
  95. data/lib/mindee/product/invoice/invoice_v4_page.rb +32 -0
  96. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +36 -0
  97. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +65 -0
  98. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb +32 -0
  99. data/lib/mindee/product/passport/passport_v1.rb +36 -0
  100. data/lib/mindee/{parsing/prediction/fr/id_card/id_card_v1.rb → product/passport/passport_v1_document.rb} +45 -45
  101. data/lib/mindee/product/passport/passport_v1_page.rb +32 -0
  102. data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +36 -0
  103. data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +83 -0
  104. data/lib/mindee/product/proof_of_address/proof_of_address_v1_page.rb +32 -0
  105. data/lib/mindee/product/receipt/receipt_v4.rb +36 -0
  106. data/lib/mindee/product/receipt/receipt_v4_document.rb +86 -0
  107. data/lib/mindee/product/receipt/receipt_v4_page.rb +32 -0
  108. data/lib/mindee/product/receipt/receipt_v5.rb +36 -0
  109. data/lib/mindee/product/receipt/receipt_v5_document.rb +138 -0
  110. data/lib/mindee/product/receipt/receipt_v5_line_item.rb +69 -0
  111. data/lib/mindee/product/receipt/receipt_v5_page.rb +32 -0
  112. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +38 -0
  113. data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +73 -0
  114. data/lib/mindee/product/us/bank_check/bank_check_v1_page.rb +34 -0
  115. data/lib/mindee/product.rb +16 -0
  116. data/lib/mindee/version.rb +2 -1
  117. data/lib/mindee.rb +3 -1
  118. metadata +87 -38
  119. data/docs/code_samples/shipping_containers_v1.txt +0 -14
  120. data/lib/mindee/document_config.rb +0 -60
  121. data/lib/mindee/parsing/document.rb +0 -31
  122. data/lib/mindee/parsing/error.rb +0 -22
  123. data/lib/mindee/parsing/inference.rb +0 -53
  124. data/lib/mindee/parsing/page.rb +0 -46
  125. data/lib/mindee/parsing/prediction/base.rb +0 -30
  126. data/lib/mindee/parsing/prediction/common_fields/amount.rb +0 -21
  127. data/lib/mindee/parsing/prediction/common_fields/base.rb +0 -72
  128. data/lib/mindee/parsing/prediction/common_fields/company_registration.rb +0 -17
  129. data/lib/mindee/parsing/prediction/common_fields/date.rb +0 -30
  130. data/lib/mindee/parsing/prediction/common_fields/locale.rb +0 -45
  131. data/lib/mindee/parsing/prediction/common_fields/payment_details.rb +0 -33
  132. data/lib/mindee/parsing/prediction/common_fields/position.rb +0 -39
  133. data/lib/mindee/parsing/prediction/common_fields/tax.rb +0 -40
  134. data/lib/mindee/parsing/prediction/common_fields/text.rb +0 -12
  135. data/lib/mindee/parsing/prediction/common_fields.rb +0 -11
  136. data/lib/mindee/parsing/prediction/custom/custom_v1.rb +0 -58
  137. data/lib/mindee/parsing/prediction/custom/fields.rb +0 -91
  138. data/lib/mindee/parsing/prediction/eu/license_plate/license_plate_v1.rb +0 -34
  139. data/lib/mindee/parsing/prediction/financial_document/financial_document_v1.rb +0 -237
  140. data/lib/mindee/parsing/prediction/financial_document/financial_document_v1_line_item.rb +0 -58
  141. data/lib/mindee/parsing/prediction/fr/bank_account_details/bank_account_details_v1.rb +0 -40
  142. data/lib/mindee/parsing/prediction/fr/carte_vitale/carte_vitale_v1.rb +0 -49
  143. data/lib/mindee/parsing/prediction/invoice/invoice_v4.rb +0 -212
  144. data/lib/mindee/parsing/prediction/invoice/invoice_v4_line_item.rb +0 -58
  145. data/lib/mindee/parsing/prediction/passport/passport_v1.rb +0 -121
  146. data/lib/mindee/parsing/prediction/proof_of_address/proof_of_address_v1.rb +0 -80
  147. data/lib/mindee/parsing/prediction/receipt/receipt_v4.rb +0 -87
  148. data/lib/mindee/parsing/prediction/receipt/receipt_v5.rb +0 -136
  149. data/lib/mindee/parsing/prediction/receipt/receipt_v5_line_item.rb +0 -37
  150. data/lib/mindee/parsing/prediction/shipping_container/shipping_container_v1.rb +0 -38
  151. data/lib/mindee/parsing/prediction/us/bank_check/bank_check_v1.rb +0 -70
  152. data/lib/mindee/parsing/prediction.rb +0 -15
@@ -0,0 +1,138 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'receipt_v5_line_item'
5
+
6
+ module Mindee
7
+ module Product
8
+ module Receipt
9
+ # Expense Receipt V5 document prediction.
10
+ class ReceiptV5Document < Mindee::Parsing::Common::Prediction
11
+ include Mindee::Parsing::Standard
12
+ # The purchase category among predefined classes.
13
+ # @return [Mindee::Parsing::Standard::ClassificationField]
14
+ attr_reader :category
15
+ # The date the purchase was made.
16
+ # @return [Mindee::Parsing::Standard::DateField]
17
+ attr_reader :date
18
+ # One of: 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'.
19
+ # @return [Mindee::Parsing::Standard::ClassificationField]
20
+ attr_reader :document_type
21
+ # List of line item details.
22
+ # @return [Array<Mindee::Product::Receipt::ReceiptV5LineItem>]
23
+ attr_reader :line_items
24
+ # The locale detected on the document.
25
+ # @return [Mindee::Parsing::Standard::Locale]
26
+ attr_reader :locale
27
+ # The purchase subcategory among predefined classes for transport and food.
28
+ # @return [Mindee::Parsing::Standard::ClassificationField]
29
+ attr_reader :subcategory
30
+ # The address of the supplier or merchant.
31
+ # @return [Mindee::Parsing::Standard::TextField]
32
+ attr_reader :supplier_address
33
+ # List of company registrations associated to the supplier.
34
+ # @return [Array<Mindee::Parsing::Standard::CompanyRegistration>]
35
+ attr_reader :supplier_company_registrations
36
+ # The name of the supplier or merchant.
37
+ # @return [Mindee::Parsing::Standard::TextField]
38
+ attr_reader :supplier_name
39
+ # The phone number of the supplier or merchant.
40
+ # @return [Mindee::Parsing::Standard::TextField]
41
+ attr_reader :supplier_phone_number
42
+ # List of tax lines information.
43
+ # @return [Mindee::Parsing::Standard::Taxes]
44
+ attr_reader :taxes
45
+ # The time the purchase was made.
46
+ # @return [Mindee::Parsing::Standard::TextField]
47
+ attr_reader :time
48
+ # The total amount of tip and gratuity.
49
+ # @return [Mindee::Parsing::Standard::AmountField]
50
+ attr_reader :tip
51
+ # The total amount paid: includes taxes, discounts, fees, tips, and gratuity.
52
+ # @return [Mindee::Parsing::Standard::AmountField]
53
+ attr_reader :total_amount
54
+ # The net amount paid: does not include taxes, fees, and discounts.
55
+ # @return [Mindee::Parsing::Standard::AmountField]
56
+ attr_reader :total_net
57
+ # The total amount of taxes.
58
+ # @return [Mindee::Parsing::Standard::AmountField]
59
+ attr_reader :total_tax
60
+
61
+ # @param prediction [Hash]
62
+ # @param page_id [Integer, nil]
63
+ def initialize(prediction, page_id)
64
+ super()
65
+ @category = ClassificationField.new(prediction['category'], page_id)
66
+ @date = DateField.new(prediction['date'], page_id)
67
+ @document_type = ClassificationField.new(prediction['document_type'], page_id)
68
+ @line_items = []
69
+ prediction['line_items'].each do |item|
70
+ @line_items.push(ReceiptV5LineItem.new(item, page_id))
71
+ end
72
+ @locale = Locale.new(prediction['locale'], page_id)
73
+ @subcategory = ClassificationField.new(prediction['subcategory'], page_id)
74
+ @supplier_address = TextField.new(prediction['supplier_address'], page_id)
75
+ @supplier_company_registrations = []
76
+ prediction['supplier_company_registrations'].each do |item|
77
+ @supplier_company_registrations.push(CompanyRegistration.new(item, page_id))
78
+ end
79
+ @supplier_name = TextField.new(prediction['supplier_name'], page_id)
80
+ @supplier_phone_number = TextField.new(prediction['supplier_phone_number'], page_id)
81
+ @taxes = Taxes.new(prediction['taxes'], page_id)
82
+ @time = TextField.new(prediction['time'], page_id)
83
+ @tip = AmountField.new(prediction['tip'], page_id)
84
+ @total_amount = AmountField.new(prediction['total_amount'], page_id)
85
+ @total_net = AmountField.new(prediction['total_net'], page_id)
86
+ @total_tax = AmountField.new(prediction['total_tax'], page_id)
87
+ end
88
+
89
+ # @return [String]
90
+ def to_s
91
+ supplier_company_registrations = @supplier_company_registrations.join("\n #{' ' * 32}")
92
+ line_items = line_items_to_s
93
+ out_str = String.new
94
+ out_str << "\n:Expense Locale: #{@locale}".rstrip
95
+ out_str << "\n:Purchase Category: #{@category}".rstrip
96
+ out_str << "\n:Purchase Subcategory: #{@subcategory}".rstrip
97
+ out_str << "\n:Document Type: #{@document_type}".rstrip
98
+ out_str << "\n:Purchase Date: #{@date}".rstrip
99
+ out_str << "\n:Purchase Time: #{@time}".rstrip
100
+ out_str << "\n:Total Amount: #{@total_amount}".rstrip
101
+ out_str << "\n:Total Net: #{@total_net}".rstrip
102
+ out_str << "\n:Total Tax: #{@total_tax}".rstrip
103
+ out_str << "\n:Tip and Gratuity: #{@tip}".rstrip
104
+ out_str << "\n:Taxes:#{@taxes}".rstrip
105
+ out_str << "\n:Supplier Name: #{@supplier_name}".rstrip
106
+ out_str << "\n:Supplier Company Registrations: #{supplier_company_registrations}".rstrip
107
+ out_str << "\n:Supplier Address: #{@supplier_address}".rstrip
108
+ out_str << "\n:Supplier Phone Number: #{@supplier_phone_number}".rstrip
109
+ out_str << "\n:Line Items:"
110
+ out_str << line_items
111
+ out_str[1..].to_s
112
+ end
113
+
114
+ private
115
+
116
+ def line_items_separator(char)
117
+ " +#{char * 38}+#{char * 10}+#{char * 14}+#{char * 12}+"
118
+ end
119
+
120
+ def line_items_to_s
121
+ return '' if @line_items.empty?
122
+
123
+ line_items = @line_items.map(&:to_table_line).join("\n#{line_items_separator('-')}\n ")
124
+ out_str = String.new
125
+ out_str << "\n#{line_items_separator('-')}"
126
+ out_str << "\n |"
127
+ out_str << ' Description |'
128
+ out_str << ' Quantity |'
129
+ out_str << ' Total Amount |'
130
+ out_str << ' Unit Price |'
131
+ out_str << "\n#{line_items_separator('=')}"
132
+ out_str << "\n #{line_items}"
133
+ out_str << "\n#{line_items_separator('-')}"
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module Receipt
8
+ # List of line item details.
9
+ class ReceiptV5LineItem < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # The item description.
12
+ # @return [String]
13
+ attr_reader :description
14
+ # The item quantity.
15
+ # @return [Float]
16
+ attr_reader :quantity
17
+ # The item total amount.
18
+ # @return [Float]
19
+ attr_reader :total_amount
20
+ # The item unit price.
21
+ # @return [Float]
22
+ attr_reader :unit_price
23
+
24
+ # @param prediction [Hash]
25
+ # @param page_id [Integer, nil]
26
+ def initialize(prediction, page_id)
27
+ super(prediction, page_id)
28
+ @description = prediction['description']
29
+ @quantity = prediction['quantity']
30
+ @total_amount = prediction['total_amount']
31
+ @unit_price = prediction['unit_price']
32
+ @page_id = page_id
33
+ end
34
+
35
+ # @return [Hash]
36
+ def printable_values
37
+ printable = {}
38
+ printable[:description] = format_for_display(@description, 36)
39
+ printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
40
+ printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
41
+ printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
42
+ printable
43
+ end
44
+
45
+ # @return [String]
46
+ def to_table_line
47
+ printable = printable_values
48
+ out_str = String.new
49
+ out_str << format('| %- 37s', printable[:description])
50
+ out_str << format('| %- 9s', printable[:quantity])
51
+ out_str << format('| %- 13s', printable[:total_amount])
52
+ out_str << format('| %- 11s', printable[:unit_price])
53
+ out_str << '|'
54
+ end
55
+
56
+ # @return [String]
57
+ def to_s
58
+ printable = printable_values
59
+ out_str = String.new
60
+ out_str << printable[:description]
61
+ out_str << printable[:quantity]
62
+ out_str << printable[:total_amount]
63
+ out_str << printable[:unit_price]
64
+ out_str.strip
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'receipt_v5_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module Receipt
9
+ # Expense Receipt V5 page.
10
+ class ReceiptV5Page < Mindee::Parsing::Common::Page
11
+ # @param prediction [Hash]
12
+ def initialize(prediction)
13
+ super(prediction)
14
+ @prediction = ReceiptV5PagePrediction.new(
15
+ prediction['prediction'],
16
+ prediction['id']
17
+ )
18
+ end
19
+ end
20
+
21
+ # Expense Receipt V5 page prediction.
22
+ class ReceiptV5PagePrediction < ReceiptV5Document
23
+ # @return [String]
24
+ def to_s
25
+ out_str = String.new
26
+ out_str << "\n#{super}"
27
+ out_str
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'bank_check_v1_document'
5
+ require_relative 'bank_check_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ module US
10
+ module BankCheck
11
+ # Bank Check Inference
12
+ class BankCheckV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'bank_check'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = BankCheckV1Document.new(prediction['prediction'], nil)
20
+ @pages = []
21
+ prediction['pages'].each do |page|
22
+ @pages.push(BankCheckV1Page.new(page))
23
+ end
24
+ end
25
+
26
+ class << self
27
+ # Name of the endpoint for this product.
28
+ # @return [String]
29
+ attr_reader :endpoint_name
30
+ # Version for this product.
31
+ # @return [String]
32
+ attr_reader :endpoint_version
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module US
8
+ module BankCheck
9
+ # Bank Check V1 document prediction.
10
+ class BankCheckV1Document < Mindee::Parsing::Common::Prediction
11
+ include Mindee::Parsing::Standard
12
+ # Payer's bank account number.
13
+ # @return [Array<Mindee::Parsing::Standard::TextField>]
14
+ attr_reader :account_number
15
+ # Amount to be paid.
16
+ # @return [Array<Mindee::Parsing::Standard::AmountField>]
17
+ attr_reader :amount
18
+ # The check number.
19
+ # @return [Mindee::Parsing::Standard::TextField]
20
+ attr_reader :check_number
21
+ # Payer's bank account routing number.
22
+ # @return [Mindee::Parsing::Standard::TextField]
23
+ attr_reader :routing_number
24
+ # Date the check was issued.
25
+ # @return [Mindee::Parsing::Standard::DateField]
26
+ attr_reader :date
27
+ # The positions of the signatures on the image.
28
+ # @return [Array<Parsing::Standard::PositionField>]
29
+ attr_reader :signatures_positions
30
+ # Check's position in the image.
31
+ # @return [Parsing::Standard::PositionField]
32
+ attr_reader :check_position
33
+ # List of payees (full name or company name).
34
+ # @return [Array<Mindee::Parsing::Standard::TextField>]
35
+ attr_reader :payees
36
+
37
+ # @param prediction [Hash]
38
+ # @param page_id [Integer, nil]
39
+ def initialize(prediction, page_id)
40
+ super()
41
+ @account_number = TextField.new(prediction['account_number'], page_id)
42
+ @amount = AmountField.new(prediction['amount'], page_id)
43
+ @check_number = TextField.new(prediction['check_number'], page_id)
44
+ @date = DateField.new(prediction['date'], page_id)
45
+ @check_position = PositionField.new(prediction['check_position'], page_id)
46
+ @routing_number = TextField.new(prediction['routing_number'], page_id)
47
+ @signatures_positions = []
48
+ prediction['signatures_positions'].each do |item|
49
+ @signatures_positions.push(PositionField.new(item, page_id))
50
+ end
51
+ @payees = []
52
+ prediction['payees'].each do |item|
53
+ @payees.push(TextField.new(item, page_id))
54
+ end
55
+ end
56
+
57
+ # @return [String]
58
+ def to_s
59
+ payees = @payees.map(&:value).join(', ')
60
+ out_str = String.new
61
+ out_str << "\n:Routing number: #{@routing_number}".rstrip
62
+ out_str << "\n:Account number: #{@account_number}".rstrip
63
+ out_str << "\n:Check number: #{@check_number}".rstrip
64
+ out_str << "\n:Date: #{@date}".rstrip
65
+ out_str << "\n:Amount: #{@amount}".rstrip
66
+ out_str << "\n:Payees: #{payees}".rstrip
67
+ out_str[1..].to_s
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'bank_check_v1_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module US
9
+ module BankCheck
10
+ # Bank Check V1 page.
11
+ class BankCheckV1Page < Mindee::Parsing::Common::Page
12
+ # @param prediction [Hash]
13
+ def initialize(prediction)
14
+ super(prediction)
15
+ @prediction = BankCheckV1PagePrediction.new(
16
+ prediction['prediction'],
17
+ prediction['id']
18
+ )
19
+ end
20
+ end
21
+
22
+ # Bank Check V1 page prediction.
23
+ class BankCheckV1PagePrediction < BankCheckV1Document
24
+ # @return [String]
25
+ def to_s
26
+ out_str = String.new
27
+ out_str << "\n#{super}"
28
+ out_str
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'product/custom/custom_v1'
4
+ require_relative 'product/proof_of_address/proof_of_address_v1'
5
+ require_relative 'product/financial_document/financial_document_v1'
6
+ require_relative 'product/invoice/invoice_v4'
7
+ require_relative 'product/passport/passport_v1'
8
+ require_relative 'product/receipt/receipt_v4'
9
+ require_relative 'product/receipt/receipt_v5'
10
+ require_relative 'product/eu/license_plate/license_plate_v1'
11
+ require_relative 'product/us/bank_check/bank_check_v1'
12
+ require_relative 'product/fr/bank_account_details/bank_account_details_v1'
13
+ require_relative 'product/fr/bank_account_details/bank_account_details_v2'
14
+ require_relative 'product/fr/carte_vitale/carte_vitale_v1'
15
+ require_relative 'product/fr/id_card/id_card_v1'
16
+ require_relative 'product/invoice_splitter/invoice_splitter_v1'
@@ -2,8 +2,9 @@
2
2
 
3
3
  # Mindee
4
4
  module Mindee
5
- VERSION = '2.2.0'
5
+ VERSION = '3.0.0'
6
6
 
7
+ # @return [String]
7
8
  def self.find_platform
8
9
  host = RbConfig::CONFIG['host_os']
9
10
  platforms = {
data/lib/mindee.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require 'mindee/client'
4
4
 
5
5
  module Mindee
6
- class Error < StandardError
6
+ module HTTP
7
+ class HttpError < StandardError
8
+ end
7
9
  end
8
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mindee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindee, SA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-16 00:00:00.000000000 Z
11
+ date: 2023-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: marcel
@@ -118,6 +118,7 @@ files:
118
118
  - bin/console
119
119
  - bin/mindee.rb
120
120
  - docs/code_samples/bank_account_details_v1.txt
121
+ - docs/code_samples/bank_account_details_v2.txt
121
122
  - docs/code_samples/bank_check_v1.txt
122
123
  - docs/code_samples/carte_vitale_v1.txt
123
124
  - docs/code_samples/custom_v1.txt
@@ -126,11 +127,11 @@ files:
126
127
  - docs/code_samples/expense_receipts_v5.txt
127
128
  - docs/code_samples/financial_document_v1.txt
128
129
  - docs/code_samples/idcard_fr_v1.txt
130
+ - docs/code_samples/invoice_splitter_v1_async.txt
129
131
  - docs/code_samples/invoices_v4.txt
130
132
  - docs/code_samples/license_plates_v1.txt
131
133
  - docs/code_samples/passport_v1.txt
132
134
  - docs/code_samples/proof_of_address_v1.txt
133
- - docs/code_samples/shipping_containers_v1.txt
134
135
  - docs/ruby-api-builder.md
135
136
  - docs/ruby-getting-started.md
136
137
  - docs/ruby-invoice-ocr.md
@@ -138,46 +139,94 @@ files:
138
139
  - docs/ruby-receipt-ocr.md
139
140
  - lib/mindee.rb
140
141
  - lib/mindee/client.rb
141
- - lib/mindee/document_config.rb
142
142
  - lib/mindee/geometry.rb
143
+ - lib/mindee/geometry/min_max.rb
144
+ - lib/mindee/geometry/point.rb
145
+ - lib/mindee/geometry/polygon.rb
146
+ - lib/mindee/geometry/quadrilateral.rb
147
+ - lib/mindee/geometry/utils.rb
148
+ - lib/mindee/http.rb
143
149
  - lib/mindee/http/endpoint.rb
144
150
  - lib/mindee/input.rb
145
- - lib/mindee/input/pdf_processing.rb
146
151
  - lib/mindee/input/sources.rb
147
152
  - lib/mindee/parsing.rb
148
- - lib/mindee/parsing/document.rb
149
- - lib/mindee/parsing/error.rb
150
- - lib/mindee/parsing/inference.rb
151
- - lib/mindee/parsing/page.rb
152
- - lib/mindee/parsing/prediction.rb
153
- - lib/mindee/parsing/prediction/base.rb
154
- - lib/mindee/parsing/prediction/common_fields.rb
155
- - lib/mindee/parsing/prediction/common_fields/amount.rb
156
- - lib/mindee/parsing/prediction/common_fields/base.rb
157
- - lib/mindee/parsing/prediction/common_fields/company_registration.rb
158
- - lib/mindee/parsing/prediction/common_fields/date.rb
159
- - lib/mindee/parsing/prediction/common_fields/locale.rb
160
- - lib/mindee/parsing/prediction/common_fields/payment_details.rb
161
- - lib/mindee/parsing/prediction/common_fields/position.rb
162
- - lib/mindee/parsing/prediction/common_fields/tax.rb
163
- - lib/mindee/parsing/prediction/common_fields/text.rb
164
- - lib/mindee/parsing/prediction/custom/custom_v1.rb
165
- - lib/mindee/parsing/prediction/custom/fields.rb
166
- - lib/mindee/parsing/prediction/eu/license_plate/license_plate_v1.rb
167
- - lib/mindee/parsing/prediction/financial_document/financial_document_v1.rb
168
- - lib/mindee/parsing/prediction/financial_document/financial_document_v1_line_item.rb
169
- - lib/mindee/parsing/prediction/fr/bank_account_details/bank_account_details_v1.rb
170
- - lib/mindee/parsing/prediction/fr/carte_vitale/carte_vitale_v1.rb
171
- - lib/mindee/parsing/prediction/fr/id_card/id_card_v1.rb
172
- - lib/mindee/parsing/prediction/invoice/invoice_v4.rb
173
- - lib/mindee/parsing/prediction/invoice/invoice_v4_line_item.rb
174
- - lib/mindee/parsing/prediction/passport/passport_v1.rb
175
- - lib/mindee/parsing/prediction/proof_of_address/proof_of_address_v1.rb
176
- - lib/mindee/parsing/prediction/receipt/receipt_v4.rb
177
- - lib/mindee/parsing/prediction/receipt/receipt_v5.rb
178
- - lib/mindee/parsing/prediction/receipt/receipt_v5_line_item.rb
179
- - lib/mindee/parsing/prediction/shipping_container/shipping_container_v1.rb
180
- - lib/mindee/parsing/prediction/us/bank_check/bank_check_v1.rb
153
+ - lib/mindee/parsing/common.rb
154
+ - lib/mindee/parsing/common/api_response.rb
155
+ - lib/mindee/parsing/common/document.rb
156
+ - lib/mindee/parsing/common/error.rb
157
+ - lib/mindee/parsing/common/inference.rb
158
+ - lib/mindee/parsing/common/ocr.rb
159
+ - lib/mindee/parsing/common/ocr/mvision_v1.rb
160
+ - lib/mindee/parsing/common/ocr/ocr.rb
161
+ - lib/mindee/parsing/common/orientation.rb
162
+ - lib/mindee/parsing/common/page.rb
163
+ - lib/mindee/parsing/common/prediction.rb
164
+ - lib/mindee/parsing/common/product.rb
165
+ - lib/mindee/parsing/custom.rb
166
+ - lib/mindee/parsing/custom/classification_field.rb
167
+ - lib/mindee/parsing/custom/list_field.rb
168
+ - lib/mindee/parsing/standard.rb
169
+ - lib/mindee/parsing/standard/amount_field.rb
170
+ - lib/mindee/parsing/standard/base_field.rb
171
+ - lib/mindee/parsing/standard/classification_field.rb
172
+ - lib/mindee/parsing/standard/company_registration_field.rb
173
+ - lib/mindee/parsing/standard/date_field.rb
174
+ - lib/mindee/parsing/standard/locale_field.rb
175
+ - lib/mindee/parsing/standard/payment_details_field.rb
176
+ - lib/mindee/parsing/standard/position_field.rb
177
+ - lib/mindee/parsing/standard/tax_field.rb
178
+ - lib/mindee/parsing/standard/text_field.rb
179
+ - lib/mindee/pdf.rb
180
+ - lib/mindee/pdf/pdf_processing.rb
181
+ - lib/mindee/pdf/pdf_tools.rb
182
+ - lib/mindee/product.rb
183
+ - lib/mindee/product/.rubocop.yml
184
+ - lib/mindee/product/custom/custom_v1.rb
185
+ - lib/mindee/product/custom/custom_v1_document.rb
186
+ - lib/mindee/product/custom/custom_v1_page.rb
187
+ - lib/mindee/product/eu/license_plate/license_plate_v1.rb
188
+ - lib/mindee/product/eu/license_plate/license_plate_v1_document.rb
189
+ - lib/mindee/product/eu/license_plate/license_plate_v1_page.rb
190
+ - lib/mindee/product/financial_document/financial_document_v1.rb
191
+ - lib/mindee/product/financial_document/financial_document_v1_document.rb
192
+ - lib/mindee/product/financial_document/financial_document_v1_line_item.rb
193
+ - lib/mindee/product/financial_document/financial_document_v1_page.rb
194
+ - lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb
195
+ - lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb
196
+ - lib/mindee/product/fr/bank_account_details/bank_account_details_v1_page.rb
197
+ - lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb
198
+ - lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb
199
+ - lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb
200
+ - lib/mindee/product/fr/bank_account_details/bank_account_details_v2_page.rb
201
+ - lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb
202
+ - lib/mindee/product/fr/carte_vitale/carte_vitale_v1_document.rb
203
+ - lib/mindee/product/fr/carte_vitale/carte_vitale_v1_page.rb
204
+ - lib/mindee/product/fr/id_card/id_card_v1.rb
205
+ - lib/mindee/product/fr/id_card/id_card_v1_document.rb
206
+ - lib/mindee/product/fr/id_card/id_card_v1_page.rb
207
+ - lib/mindee/product/invoice/invoice_v4.rb
208
+ - lib/mindee/product/invoice/invoice_v4_document.rb
209
+ - lib/mindee/product/invoice/invoice_v4_line_item.rb
210
+ - lib/mindee/product/invoice/invoice_v4_page.rb
211
+ - lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb
212
+ - lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb
213
+ - lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb
214
+ - lib/mindee/product/passport/passport_v1.rb
215
+ - lib/mindee/product/passport/passport_v1_document.rb
216
+ - lib/mindee/product/passport/passport_v1_page.rb
217
+ - lib/mindee/product/proof_of_address/proof_of_address_v1.rb
218
+ - lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb
219
+ - lib/mindee/product/proof_of_address/proof_of_address_v1_page.rb
220
+ - lib/mindee/product/receipt/receipt_v4.rb
221
+ - lib/mindee/product/receipt/receipt_v4_document.rb
222
+ - lib/mindee/product/receipt/receipt_v4_page.rb
223
+ - lib/mindee/product/receipt/receipt_v5.rb
224
+ - lib/mindee/product/receipt/receipt_v5_document.rb
225
+ - lib/mindee/product/receipt/receipt_v5_line_item.rb
226
+ - lib/mindee/product/receipt/receipt_v5_page.rb
227
+ - lib/mindee/product/us/bank_check/bank_check_v1.rb
228
+ - lib/mindee/product/us/bank_check/bank_check_v1_document.rb
229
+ - lib/mindee/product/us/bank_check/bank_check_v1_page.rb
181
230
  - lib/mindee/version.rb
182
231
  - mindee.gemspec
183
232
  homepage: https://github.com/mindee/mindee-api-ruby
@@ -1,14 +0,0 @@
1
- require 'mindee'
2
-
3
- # Init a new client
4
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
5
-
6
- # Load a file from disk and parse it
7
- result = mindee_client.doc_from_path('/path/to/the/file.ext')
8
- .parse(Mindee::Prediction::ShippingContainerV1)
9
-
10
- # Print a full summary of the parsed data in RST format
11
- puts result
12
-
13
- # Print the document-level parsed data
14
- # puts result.inference.prediction