mindee 3.1.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +57 -7
- data/bin/mindee.rb +160 -83
- data/docs/bank_account_details_v2.md +137 -0
- data/docs/bank_check_v1.md +179 -0
- data/docs/barcode_reader_v1.md +104 -0
- data/docs/carte_vitale_v1.md +123 -0
- data/docs/code_samples/barcode_reader_v1.txt +19 -0
- data/docs/code_samples/cropper_v1.txt +16 -0
- data/docs/code_samples/idcard_fr_v2.txt +19 -0
- data/docs/code_samples/invoice_splitter_v1_async.txt +6 -54
- data/docs/code_samples/multi_receipts_detector_v1.txt +19 -0
- data/docs/code_samples/us_w9_v1.txt +16 -0
- data/docs/cropper_v1.md +97 -0
- data/docs/custom_v1.md +101 -0
- data/docs/expense_receipts_v5.md +306 -0
- data/docs/financial_document_v1.md +384 -0
- data/docs/{ruby-getting-started.md → getting_started.md} +22 -6
- data/docs/idcard_fr_v2.md +253 -0
- data/docs/invoice_splitter_v1.md +85 -0
- data/docs/invoices_v4.md +369 -0
- data/docs/license_plates_v1.md +91 -0
- data/docs/multi_receipts_detector_v1.md +105 -0
- data/docs/passport_v1.md +186 -0
- data/docs/proof_of_address_v1.md +207 -0
- data/docs/us_driver_license_v1.md +268 -0
- data/docs/us_w9_v1.md +207 -0
- data/lib/mindee/client.rb +95 -16
- data/lib/mindee/geometry/quadrilateral.rb +5 -0
- data/lib/mindee/http/.rubocop.yml +8 -0
- data/lib/mindee/http/endpoint.rb +14 -6
- data/lib/mindee/http/error.rb +104 -0
- data/lib/mindee/http.rb +1 -0
- data/lib/mindee/input/sources.rb +83 -14
- data/lib/mindee/parsing/common/api_response.rb +11 -1
- data/lib/mindee/parsing/common/inference.rb +2 -2
- data/lib/mindee/parsing/common/ocr/ocr.rb +1 -0
- data/lib/mindee/parsing/common.rb +0 -1
- data/lib/mindee/parsing/standard/company_registration_field.rb +1 -1
- data/lib/mindee/parsing/standard/locale_field.rb +1 -1
- data/lib/mindee/parsing/standard/payment_details_field.rb +1 -1
- data/lib/mindee/parsing/standard/position_field.rb +10 -3
- data/lib/mindee/parsing/standard/{text_field.rb → string_field.rb} +1 -1
- data/lib/mindee/parsing/standard.rb +1 -1
- data/lib/mindee/pdf/pdf_processing.rb +2 -1
- data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +37 -0
- data/lib/mindee/product/barcode_reader/barcode_reader_v1_document.rb +44 -0
- data/lib/mindee/product/barcode_reader/barcode_reader_v1_page.rb +32 -0
- data/lib/mindee/product/cropper/cropper_v1.rb +37 -0
- data/lib/mindee/product/cropper/cropper_v1_document.rb +13 -0
- data/lib/mindee/product/cropper/cropper_v1_page.rb +49 -0
- data/lib/mindee/product/custom/custom_v1.rb +1 -0
- data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +1 -0
- data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +2 -2
- data/lib/mindee/product/financial_document/financial_document_v1.rb +1 -0
- data/lib/mindee/product/financial_document/financial_document_v1_document.rb +24 -24
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +1 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +6 -6
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +1 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +6 -6
- data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +1 -0
- data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_document.rb +6 -6
- data/lib/mindee/product/fr/id_card/id_card_v1.rb +1 -0
- data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +16 -16
- data/lib/mindee/product/fr/id_card/id_card_v2.rb +39 -0
- data/lib/mindee/product/fr/id_card/id_card_v2_document.rb +107 -0
- data/lib/mindee/product/fr/id_card/id_card_v2_page.rb +53 -0
- data/lib/mindee/product/invoice/invoice_v4.rb +1 -0
- data/lib/mindee/product/invoice/invoice_v4_document.rb +24 -24
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +1 -0
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +5 -3
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +37 -0
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +35 -0
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +32 -0
- data/lib/mindee/product/passport/passport_v1.rb +1 -0
- data/lib/mindee/product/passport/passport_v1_document.rb +16 -16
- data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +1 -0
- data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +14 -14
- data/lib/mindee/product/receipt/receipt_v4_document.rb +6 -6
- data/lib/mindee/product/receipt/receipt_v5.rb +1 -0
- data/lib/mindee/product/receipt/receipt_v5_document.rb +12 -12
- data/lib/mindee/product/us/bank_check/bank_check_v1.rb +1 -0
- data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +8 -8
- data/lib/mindee/product/us/driver_license/driver_license_v1.rb +1 -0
- data/lib/mindee/product/us/driver_license/driver_license_v1_document.rb +28 -28
- data/lib/mindee/product/us/w9/w9_v1.rb +39 -0
- data/lib/mindee/product/us/w9/w9_v1_document.rb +15 -0
- data/lib/mindee/product/us/w9/w9_v1_page.rb +102 -0
- data/lib/mindee/product.rb +5 -0
- data/lib/mindee/version.rb +5 -1
- data/lib/mindee.rb +47 -0
- metadata +43 -9
- data/docs/ruby-api-builder.md +0 -123
- data/docs/ruby-invoice-ocr.md +0 -271
- data/docs/ruby-passport-ocr.md +0 -165
- data/docs/ruby-receipt-ocr.md +0 -196
- data/lib/mindee/parsing/common/error.rb +0 -24
@@ -10,78 +10,78 @@ module Mindee
|
|
10
10
|
class DriverLicenseV1Document < Mindee::Parsing::Common::Prediction
|
11
11
|
include Mindee::Parsing::Standard
|
12
12
|
# US driver license holders address
|
13
|
-
# @return [Mindee::Parsing::Standard::
|
13
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
14
14
|
attr_reader :address
|
15
15
|
# US driver license holders date of birth
|
16
16
|
# @return [Mindee::Parsing::Standard::DateField]
|
17
17
|
attr_reader :date_of_birth
|
18
18
|
# Document Discriminator Number of the US Driver License
|
19
|
-
# @return [Mindee::Parsing::Standard::
|
19
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
20
20
|
attr_reader :dd_number
|
21
21
|
# US driver license holders class
|
22
|
-
# @return [Mindee::Parsing::Standard::
|
22
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
23
23
|
attr_reader :dl_class
|
24
24
|
# ID number of the US Driver License.
|
25
|
-
# @return [Mindee::Parsing::Standard::
|
25
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
26
26
|
attr_reader :driver_license_id
|
27
27
|
# US driver license holders endorsements
|
28
|
-
# @return [Mindee::Parsing::Standard::
|
28
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
29
29
|
attr_reader :endorsements
|
30
30
|
# Date on which the documents expires.
|
31
31
|
# @return [Mindee::Parsing::Standard::DateField]
|
32
32
|
attr_reader :expiry_date
|
33
33
|
# US driver license holders eye colour
|
34
|
-
# @return [Mindee::Parsing::Standard::
|
34
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
35
35
|
attr_reader :eye_color
|
36
36
|
# US driver license holders first name(s)
|
37
|
-
# @return [Mindee::Parsing::Standard::
|
37
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
38
38
|
attr_reader :first_name
|
39
39
|
# US driver license holders hair colour
|
40
|
-
# @return [Mindee::Parsing::Standard::
|
40
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
41
41
|
attr_reader :hair_color
|
42
42
|
# US driver license holders hight
|
43
|
-
# @return [Mindee::Parsing::Standard::
|
43
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
44
44
|
attr_reader :height
|
45
45
|
# Date on which the documents was issued.
|
46
46
|
# @return [Mindee::Parsing::Standard::DateField]
|
47
47
|
attr_reader :issued_date
|
48
48
|
# US driver license holders last name
|
49
|
-
# @return [Mindee::Parsing::Standard::
|
49
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
50
50
|
attr_reader :last_name
|
51
51
|
# US driver license holders restrictions
|
52
|
-
# @return [Mindee::Parsing::Standard::
|
52
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
53
53
|
attr_reader :restrictions
|
54
54
|
# US driver license holders gender
|
55
|
-
# @return [Mindee::Parsing::Standard::
|
55
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
56
56
|
attr_reader :sex
|
57
57
|
# US State
|
58
|
-
# @return [Mindee::Parsing::Standard::
|
58
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
59
59
|
attr_reader :state
|
60
60
|
# US driver license holders weight
|
61
|
-
# @return [Mindee::Parsing::Standard::
|
61
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
62
62
|
attr_reader :weight
|
63
63
|
|
64
64
|
# @param prediction [Hash]
|
65
65
|
# @param page_id [Integer, nil]
|
66
66
|
def initialize(prediction, page_id)
|
67
67
|
super()
|
68
|
-
@address =
|
68
|
+
@address = StringField.new(prediction['address'], page_id)
|
69
69
|
@date_of_birth = DateField.new(prediction['date_of_birth'], page_id)
|
70
|
-
@dd_number =
|
71
|
-
@dl_class =
|
72
|
-
@driver_license_id =
|
73
|
-
@endorsements =
|
70
|
+
@dd_number = StringField.new(prediction['dd_number'], page_id)
|
71
|
+
@dl_class = StringField.new(prediction['dl_class'], page_id)
|
72
|
+
@driver_license_id = StringField.new(prediction['driver_license_id'], page_id)
|
73
|
+
@endorsements = StringField.new(prediction['endorsements'], page_id)
|
74
74
|
@expiry_date = DateField.new(prediction['expiry_date'], page_id)
|
75
|
-
@eye_color =
|
76
|
-
@first_name =
|
77
|
-
@hair_color =
|
78
|
-
@height =
|
75
|
+
@eye_color = StringField.new(prediction['eye_color'], page_id)
|
76
|
+
@first_name = StringField.new(prediction['first_name'], page_id)
|
77
|
+
@hair_color = StringField.new(prediction['hair_color'], page_id)
|
78
|
+
@height = StringField.new(prediction['height'], page_id)
|
79
79
|
@issued_date = DateField.new(prediction['issued_date'], page_id)
|
80
|
-
@last_name =
|
81
|
-
@restrictions =
|
82
|
-
@sex =
|
83
|
-
@state =
|
84
|
-
@weight =
|
80
|
+
@last_name = StringField.new(prediction['last_name'], page_id)
|
81
|
+
@restrictions = StringField.new(prediction['restrictions'], page_id)
|
82
|
+
@sex = StringField.new(prediction['sex'], page_id)
|
83
|
+
@state = StringField.new(prediction['state'], page_id)
|
84
|
+
@weight = StringField.new(prediction['weight'], page_id)
|
85
85
|
end
|
86
86
|
|
87
87
|
# @return [String]
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../parsing'
|
4
|
+
require_relative 'w9_v1_document'
|
5
|
+
require_relative 'w9_v1_page'
|
6
|
+
|
7
|
+
module Mindee
|
8
|
+
module Product
|
9
|
+
module US
|
10
|
+
# US W9 module.
|
11
|
+
module W9
|
12
|
+
# US W9 V1 prediction inference.
|
13
|
+
class W9V1 < Mindee::Parsing::Common::Inference
|
14
|
+
@endpoint_name = 'us_w9'
|
15
|
+
@endpoint_version = '1'
|
16
|
+
|
17
|
+
# @param prediction [Hash]
|
18
|
+
def initialize(prediction)
|
19
|
+
super
|
20
|
+
@prediction = W9V1Document.new
|
21
|
+
@pages = []
|
22
|
+
prediction['pages'].each do |page|
|
23
|
+
@pages.push(W9V1Page.new(page))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
# Name of the endpoint for this product.
|
29
|
+
# @return [String]
|
30
|
+
attr_reader :endpoint_name
|
31
|
+
# Version for this product.
|
32
|
+
# @return [String]
|
33
|
+
attr_reader :endpoint_version
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../parsing'
|
4
|
+
|
5
|
+
module Mindee
|
6
|
+
module Product
|
7
|
+
module US
|
8
|
+
module W9
|
9
|
+
# US W9 V1 document prediction.
|
10
|
+
class W9V1Document < Mindee::Parsing::Common::Prediction
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../parsing'
|
4
|
+
require_relative 'w9_v1_document'
|
5
|
+
|
6
|
+
module Mindee
|
7
|
+
module Product
|
8
|
+
module US
|
9
|
+
module W9
|
10
|
+
# US W9 V1 page.
|
11
|
+
class W9V1Page < Mindee::Parsing::Common::Page
|
12
|
+
# @param prediction [Hash]
|
13
|
+
def initialize(prediction)
|
14
|
+
super(prediction)
|
15
|
+
@prediction = W9V1PagePrediction.new(
|
16
|
+
prediction['prediction'],
|
17
|
+
prediction['id']
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# US W9 V1 page prediction.
|
23
|
+
class W9V1PagePrediction < W9V1Document
|
24
|
+
include Mindee::Parsing::Standard
|
25
|
+
|
26
|
+
# The street address (number, street, and apt. or suite no.) of the applicant.
|
27
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
28
|
+
attr_reader :address
|
29
|
+
# The business name or disregarded entity name, if different from Name.
|
30
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
31
|
+
attr_reader :business_name
|
32
|
+
# The city, state, and ZIP code of the applicant.
|
33
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
34
|
+
attr_reader :city_state_zip
|
35
|
+
# The employer identification number.
|
36
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
37
|
+
attr_reader :ein
|
38
|
+
# Name as shown on the applicant's income tax return.
|
39
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
40
|
+
attr_reader :name
|
41
|
+
# Position of the signature date on the document.
|
42
|
+
# @return [Mindee::Parsing::Standard::PositionField]
|
43
|
+
attr_reader :signature_date_position
|
44
|
+
# Position of the signature on the document.
|
45
|
+
# @return [Mindee::Parsing::Standard::PositionField]
|
46
|
+
attr_reader :signature_position
|
47
|
+
# The applicant's social security number.
|
48
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
49
|
+
attr_reader :ssn
|
50
|
+
# The federal tax classification, which can vary depending on the revision date.
|
51
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
52
|
+
attr_reader :tax_classification
|
53
|
+
# Depending on revision year, among S, C, P or D for Limited Liability Company Classification.
|
54
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
55
|
+
attr_reader :tax_classification_llc
|
56
|
+
# Tax Classification Other Details.
|
57
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
58
|
+
attr_reader :tax_classification_other_details
|
59
|
+
# The Revision month and year of the W9 form.
|
60
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
61
|
+
attr_reader :w9_revision_date
|
62
|
+
|
63
|
+
# @param prediction [Hash]
|
64
|
+
# @param page_id [Integer, nil]
|
65
|
+
def initialize(prediction, page_id)
|
66
|
+
@address = StringField.new(prediction['address'], page_id)
|
67
|
+
@business_name = StringField.new(prediction['business_name'], page_id)
|
68
|
+
@city_state_zip = StringField.new(prediction['city_state_zip'], page_id)
|
69
|
+
@ein = StringField.new(prediction['ein'], page_id)
|
70
|
+
@name = StringField.new(prediction['name'], page_id)
|
71
|
+
@signature_date_position = PositionField.new(prediction['signature_date_position'], page_id)
|
72
|
+
@signature_position = PositionField.new(prediction['signature_position'], page_id)
|
73
|
+
@ssn = StringField.new(prediction['ssn'], page_id)
|
74
|
+
@tax_classification = StringField.new(prediction['tax_classification'], page_id)
|
75
|
+
@tax_classification_llc = StringField.new(prediction['tax_classification_llc'], page_id)
|
76
|
+
@tax_classification_other_details = StringField.new(prediction['tax_classification_other_details'], page_id)
|
77
|
+
@w9_revision_date = StringField.new(prediction['w9_revision_date'], page_id)
|
78
|
+
super()
|
79
|
+
end
|
80
|
+
|
81
|
+
# @return [String]
|
82
|
+
def to_s
|
83
|
+
out_str = String.new
|
84
|
+
out_str << "\n:Name: #{@name}".rstrip
|
85
|
+
out_str << "\n:SSN: #{@ssn}".rstrip
|
86
|
+
out_str << "\n:Address: #{@address}".rstrip
|
87
|
+
out_str << "\n:City State Zip: #{@city_state_zip}".rstrip
|
88
|
+
out_str << "\n:Business Name: #{@business_name}".rstrip
|
89
|
+
out_str << "\n:EIN: #{@ein}".rstrip
|
90
|
+
out_str << "\n:Tax Classification: #{@tax_classification}".rstrip
|
91
|
+
out_str << "\n:Tax Classification Other Details: #{@tax_classification_other_details}".rstrip
|
92
|
+
out_str << "\n:W9 Revision Date: #{@w9_revision_date}".rstrip
|
93
|
+
out_str << "\n:Signature Position: #{@signature_position}".rstrip
|
94
|
+
out_str << "\n:Signature Date Position: #{@signature_date_position}".rstrip
|
95
|
+
out_str << "\n:Tax Classification LLC: #{@tax_classification_llc}".rstrip
|
96
|
+
out_str
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/lib/mindee/product.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'product/barcode_reader/barcode_reader_v1'
|
3
4
|
require_relative 'product/custom/custom_v1'
|
4
5
|
require_relative 'product/proof_of_address/proof_of_address_v1'
|
5
6
|
require_relative 'product/financial_document/financial_document_v1'
|
6
7
|
require_relative 'product/invoice/invoice_v4'
|
8
|
+
require_relative 'product/cropper/cropper_v1'
|
9
|
+
require_relative 'product/multi_receipts_detector/multi_receipts_detector_v1'
|
7
10
|
require_relative 'product/passport/passport_v1'
|
8
11
|
require_relative 'product/receipt/receipt_v4'
|
9
12
|
require_relative 'product/receipt/receipt_v5'
|
@@ -12,6 +15,8 @@ require_relative 'product/fr/bank_account_details/bank_account_details_v1'
|
|
12
15
|
require_relative 'product/fr/bank_account_details/bank_account_details_v2'
|
13
16
|
require_relative 'product/fr/carte_vitale/carte_vitale_v1'
|
14
17
|
require_relative 'product/fr/id_card/id_card_v1'
|
18
|
+
require_relative 'product/fr/id_card/id_card_v2'
|
15
19
|
require_relative 'product/invoice_splitter/invoice_splitter_v1'
|
16
20
|
require_relative 'product/us/bank_check/bank_check_v1'
|
17
21
|
require_relative 'product/us/driver_license/driver_license_v1'
|
22
|
+
require_relative 'product/us/w9/w9_v1'
|
data/lib/mindee/version.rb
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
# Mindee
|
4
4
|
module Mindee
|
5
|
-
|
5
|
+
# Current version.
|
6
|
+
VERSION = '3.2.0'
|
6
7
|
|
8
|
+
# Finds and return the current platform.
|
7
9
|
# @return [String]
|
8
10
|
def self.find_platform
|
9
11
|
host = RbConfig::CONFIG['host_os']
|
@@ -18,5 +20,7 @@ module Mindee
|
|
18
20
|
return os unless (regexp =~ host).nil?
|
19
21
|
end
|
20
22
|
end
|
23
|
+
|
24
|
+
# Current platform.
|
21
25
|
PLATFORM = find_platform.freeze
|
22
26
|
end
|
data/lib/mindee.rb
CHANGED
@@ -3,8 +3,55 @@
|
|
3
3
|
require 'mindee/client'
|
4
4
|
|
5
5
|
module Mindee
|
6
|
+
# Mindee internal http module.
|
6
7
|
module HTTP
|
8
|
+
# Global Mindee HTTP error handler.
|
7
9
|
class HttpError < StandardError
|
8
10
|
end
|
9
11
|
end
|
12
|
+
|
13
|
+
# PDF-specific operations.
|
14
|
+
module PDF
|
15
|
+
end
|
16
|
+
|
17
|
+
# Document handling.
|
18
|
+
module Input
|
19
|
+
# Document source handling.
|
20
|
+
module Source
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parsing internals and fields.
|
25
|
+
module Parsing
|
26
|
+
# Common fields and functions.
|
27
|
+
module Common
|
28
|
+
end
|
29
|
+
|
30
|
+
# Custom fields and functions.
|
31
|
+
module Custom
|
32
|
+
end
|
33
|
+
|
34
|
+
# Standard fields and functions.
|
35
|
+
module Standard
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Document input-related internals.
|
40
|
+
module Input
|
41
|
+
end
|
42
|
+
|
43
|
+
# Collection of all internal products.
|
44
|
+
module Product
|
45
|
+
# Europe-specific products.
|
46
|
+
module EU
|
47
|
+
end
|
48
|
+
|
49
|
+
# France-specific products.
|
50
|
+
module FR
|
51
|
+
end
|
52
|
+
|
53
|
+
# US-specific products.
|
54
|
+
module US
|
55
|
+
end
|
56
|
+
end
|
10
57
|
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: 3.
|
4
|
+
version: 3.2.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-
|
11
|
+
date: 2023-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: marcel
|
@@ -117,27 +117,45 @@ files:
|
|
117
117
|
- Rakefile
|
118
118
|
- bin/console
|
119
119
|
- bin/mindee.rb
|
120
|
+
- docs/bank_account_details_v2.md
|
121
|
+
- docs/bank_check_v1.md
|
122
|
+
- docs/barcode_reader_v1.md
|
123
|
+
- docs/carte_vitale_v1.md
|
120
124
|
- docs/code_samples/bank_account_details_v1.txt
|
121
125
|
- docs/code_samples/bank_account_details_v2.txt
|
122
126
|
- docs/code_samples/bank_check_v1.txt
|
127
|
+
- docs/code_samples/barcode_reader_v1.txt
|
123
128
|
- docs/code_samples/carte_vitale_v1.txt
|
129
|
+
- docs/code_samples/cropper_v1.txt
|
124
130
|
- docs/code_samples/custom_v1.txt
|
125
131
|
- docs/code_samples/default.txt
|
126
132
|
- docs/code_samples/expense_receipts_v4.txt
|
127
133
|
- docs/code_samples/expense_receipts_v5.txt
|
128
134
|
- docs/code_samples/financial_document_v1.txt
|
129
135
|
- docs/code_samples/idcard_fr_v1.txt
|
136
|
+
- docs/code_samples/idcard_fr_v2.txt
|
130
137
|
- docs/code_samples/invoice_splitter_v1_async.txt
|
131
138
|
- docs/code_samples/invoices_v4.txt
|
132
139
|
- docs/code_samples/license_plates_v1.txt
|
140
|
+
- docs/code_samples/multi_receipts_detector_v1.txt
|
133
141
|
- docs/code_samples/passport_v1.txt
|
134
142
|
- docs/code_samples/proof_of_address_v1.txt
|
135
143
|
- docs/code_samples/us_driver_license_v1.txt
|
136
|
-
- docs/
|
137
|
-
- docs/
|
138
|
-
- docs/
|
139
|
-
- docs/
|
140
|
-
- docs/
|
144
|
+
- docs/code_samples/us_w9_v1.txt
|
145
|
+
- docs/cropper_v1.md
|
146
|
+
- docs/custom_v1.md
|
147
|
+
- docs/expense_receipts_v5.md
|
148
|
+
- docs/financial_document_v1.md
|
149
|
+
- docs/getting_started.md
|
150
|
+
- docs/idcard_fr_v2.md
|
151
|
+
- docs/invoice_splitter_v1.md
|
152
|
+
- docs/invoices_v4.md
|
153
|
+
- docs/license_plates_v1.md
|
154
|
+
- docs/multi_receipts_detector_v1.md
|
155
|
+
- docs/passport_v1.md
|
156
|
+
- docs/proof_of_address_v1.md
|
157
|
+
- docs/us_driver_license_v1.md
|
158
|
+
- docs/us_w9_v1.md
|
141
159
|
- lib/mindee.rb
|
142
160
|
- lib/mindee/client.rb
|
143
161
|
- lib/mindee/geometry.rb
|
@@ -147,14 +165,15 @@ files:
|
|
147
165
|
- lib/mindee/geometry/quadrilateral.rb
|
148
166
|
- lib/mindee/geometry/utils.rb
|
149
167
|
- lib/mindee/http.rb
|
168
|
+
- lib/mindee/http/.rubocop.yml
|
150
169
|
- lib/mindee/http/endpoint.rb
|
170
|
+
- lib/mindee/http/error.rb
|
151
171
|
- lib/mindee/input.rb
|
152
172
|
- lib/mindee/input/sources.rb
|
153
173
|
- lib/mindee/parsing.rb
|
154
174
|
- lib/mindee/parsing/common.rb
|
155
175
|
- lib/mindee/parsing/common/api_response.rb
|
156
176
|
- lib/mindee/parsing/common/document.rb
|
157
|
-
- lib/mindee/parsing/common/error.rb
|
158
177
|
- lib/mindee/parsing/common/inference.rb
|
159
178
|
- lib/mindee/parsing/common/ocr.rb
|
160
179
|
- lib/mindee/parsing/common/ocr/mvision_v1.rb
|
@@ -175,13 +194,19 @@ files:
|
|
175
194
|
- lib/mindee/parsing/standard/locale_field.rb
|
176
195
|
- lib/mindee/parsing/standard/payment_details_field.rb
|
177
196
|
- lib/mindee/parsing/standard/position_field.rb
|
197
|
+
- lib/mindee/parsing/standard/string_field.rb
|
178
198
|
- lib/mindee/parsing/standard/tax_field.rb
|
179
|
-
- lib/mindee/parsing/standard/text_field.rb
|
180
199
|
- lib/mindee/pdf.rb
|
181
200
|
- lib/mindee/pdf/pdf_processing.rb
|
182
201
|
- lib/mindee/pdf/pdf_tools.rb
|
183
202
|
- lib/mindee/product.rb
|
184
203
|
- lib/mindee/product/.rubocop.yml
|
204
|
+
- lib/mindee/product/barcode_reader/barcode_reader_v1.rb
|
205
|
+
- lib/mindee/product/barcode_reader/barcode_reader_v1_document.rb
|
206
|
+
- lib/mindee/product/barcode_reader/barcode_reader_v1_page.rb
|
207
|
+
- lib/mindee/product/cropper/cropper_v1.rb
|
208
|
+
- lib/mindee/product/cropper/cropper_v1_document.rb
|
209
|
+
- lib/mindee/product/cropper/cropper_v1_page.rb
|
185
210
|
- lib/mindee/product/custom/custom_v1.rb
|
186
211
|
- lib/mindee/product/custom/custom_v1_document.rb
|
187
212
|
- lib/mindee/product/custom/custom_v1_page.rb
|
@@ -205,6 +230,9 @@ files:
|
|
205
230
|
- lib/mindee/product/fr/id_card/id_card_v1.rb
|
206
231
|
- lib/mindee/product/fr/id_card/id_card_v1_document.rb
|
207
232
|
- lib/mindee/product/fr/id_card/id_card_v1_page.rb
|
233
|
+
- lib/mindee/product/fr/id_card/id_card_v2.rb
|
234
|
+
- lib/mindee/product/fr/id_card/id_card_v2_document.rb
|
235
|
+
- lib/mindee/product/fr/id_card/id_card_v2_page.rb
|
208
236
|
- lib/mindee/product/invoice/invoice_v4.rb
|
209
237
|
- lib/mindee/product/invoice/invoice_v4_document.rb
|
210
238
|
- lib/mindee/product/invoice/invoice_v4_line_item.rb
|
@@ -212,6 +240,9 @@ files:
|
|
212
240
|
- lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb
|
213
241
|
- lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb
|
214
242
|
- lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb
|
243
|
+
- lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb
|
244
|
+
- lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb
|
245
|
+
- lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb
|
215
246
|
- lib/mindee/product/passport/passport_v1.rb
|
216
247
|
- lib/mindee/product/passport/passport_v1_document.rb
|
217
248
|
- lib/mindee/product/passport/passport_v1_page.rb
|
@@ -231,6 +262,9 @@ files:
|
|
231
262
|
- lib/mindee/product/us/driver_license/driver_license_v1.rb
|
232
263
|
- lib/mindee/product/us/driver_license/driver_license_v1_document.rb
|
233
264
|
- lib/mindee/product/us/driver_license/driver_license_v1_page.rb
|
265
|
+
- lib/mindee/product/us/w9/w9_v1.rb
|
266
|
+
- lib/mindee/product/us/w9/w9_v1_document.rb
|
267
|
+
- lib/mindee/product/us/w9/w9_v1_page.rb
|
234
268
|
- lib/mindee/version.rb
|
235
269
|
- mindee.gemspec
|
236
270
|
homepage: https://github.com/mindee/mindee-api-ruby
|
data/docs/ruby-api-builder.md
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
The Ruby OCR SDK supports [custom-built API](https://developers.mindee.com/docs/build-your-first-document-parsing-api) from the API Builder.
|
2
|
-
|
3
|
-
If your document isn't covered by one of Mindee's Off-the-Shelf APIs, you can create your own API using the
|
4
|
-
[API Builder](https://developers.mindee.com/docs/overview).
|
5
|
-
|
6
|
-
For the following examples, we are using our own [W9s custom API](https://developers.mindee.com/docs/w9-forms-ocr),
|
7
|
-
created with the [API Builder](https://developers.mindee.com/docs/overview).
|
8
|
-
|
9
|
-
> 📘 **Info**
|
10
|
-
>
|
11
|
-
> We used a data model that will be different from yours.
|
12
|
-
> To modify this to your own custom API, change the `mindee_client.create_endpoint` call with your own parameters.
|
13
|
-
|
14
|
-
```ruby
|
15
|
-
require 'mindee'
|
16
|
-
|
17
|
-
# Init a new client and configure your custom document
|
18
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
19
|
-
|
20
|
-
# Create an endpoint for your custom product
|
21
|
-
custom_endpoint = mindee_client.create_endpoint(
|
22
|
-
account_name: 'john',
|
23
|
-
endpoint_name: 'wnine',
|
24
|
-
version: '1.1' # optional, if not set, uses the latest version of the model
|
25
|
-
)
|
26
|
-
```
|
27
|
-
|
28
|
-
> **Note:** If the `version` argument is set, you'll be required to update it every time a new model is trained.
|
29
|
-
> This is probably not needed for development but essential for production use.
|
30
|
-
|
31
|
-
## Parsing Documents
|
32
|
-
The client calls the `parse` method when parsing your custom document, which will return an object that you can send to the API.
|
33
|
-
If your document is not an OTS API, the document's endpoint must be specified when calling the `parse` method.
|
34
|
-
|
35
|
-
```ruby
|
36
|
-
mindee_client.parse(
|
37
|
-
input_source,
|
38
|
-
Mindee::Product::Custom::CustomV1,
|
39
|
-
endpoint: custom_endpoint
|
40
|
-
)
|
41
|
-
|
42
|
-
|
43
|
-
# Print a summary of the document prediction in RST format
|
44
|
-
puts result.document
|
45
|
-
```
|
46
|
-
|
47
|
-
> 📘 **Info**
|
48
|
-
>
|
49
|
-
> If your custom document has the same name as one of the [off-the-shelf APIs](https://developers.mindee.com/docs/what-is-off-the-shelf-api) document,
|
50
|
-
> you **must** specify your account name when creating the `create_endpoint` method:
|
51
|
-
|
52
|
-
```ruby
|
53
|
-
custom_endpoint = mindee_client.create_endpoint(
|
54
|
-
endpoint_name: 'receipt',
|
55
|
-
account_name: 'john'
|
56
|
-
)
|
57
|
-
```
|
58
|
-
|
59
|
-
## Document Fields
|
60
|
-
All the fields defined in the API builder when creating your custom document are available.
|
61
|
-
|
62
|
-
In custom documents, each field will hold an array of all the words in the document which are related to that field.
|
63
|
-
Each word is an object that has the text content, geometry information, and confidence score.
|
64
|
-
|
65
|
-
Value fields can be accessed via the `fields` attribute.
|
66
|
-
|
67
|
-
Classification fields can be accessed via the `classifications` attribute.
|
68
|
-
|
69
|
-
> 📘 **Info**
|
70
|
-
>
|
71
|
-
> Both document level and page level objects work in the same way.
|
72
|
-
|
73
|
-
### Fields Attribute
|
74
|
-
The `fields` attribute is a hashmap with the following structure:
|
75
|
-
|
76
|
-
* key: the API name of the field, as a `symbol`
|
77
|
-
* value: a `ListField` object which has a `values` attribute, containing a list of all values found for the field.
|
78
|
-
|
79
|
-
Individual field values can be accessed by using the field's API name, in the examples below we'll use the `address` field.
|
80
|
-
|
81
|
-
```ruby
|
82
|
-
# raw data, list of each word object
|
83
|
-
pp result.document.inference.prediction.fields[:address].values
|
84
|
-
|
85
|
-
# list of all values
|
86
|
-
puts result.document.inference.prediction.fields[:address].contents_list
|
87
|
-
|
88
|
-
# default string representation
|
89
|
-
puts result.document.inference.prediction.fields[:address].to_s
|
90
|
-
|
91
|
-
# custom string representation
|
92
|
-
puts result.document.inference.prediction.fields[:address].contents_str(separator: '_')
|
93
|
-
```
|
94
|
-
|
95
|
-
To iterate over all the fields:
|
96
|
-
```ruby
|
97
|
-
result.document.inference.prediction.fields.each do |name, info|
|
98
|
-
puts name
|
99
|
-
puts info.values
|
100
|
-
end
|
101
|
-
```
|
102
|
-
|
103
|
-
### Classifications Attribute
|
104
|
-
The `classifications` attribute is a hashmap with the following structure:
|
105
|
-
|
106
|
-
* key: the API name of the field, as a `symbol`
|
107
|
-
* value: a `ClassificationField` object which has a `value` attribute, containing a string representation of the detected classification.
|
108
|
-
|
109
|
-
```ruby
|
110
|
-
# raw data, list of each word object
|
111
|
-
puts result.document.classifications[:doc_type].value
|
112
|
-
```
|
113
|
-
|
114
|
-
To iterate over all the classifications:
|
115
|
-
```ruby
|
116
|
-
result.document.classifications.each do |name, info|
|
117
|
-
puts name
|
118
|
-
puts info.value
|
119
|
-
end
|
120
|
-
```
|
121
|
-
|
122
|
-
## Questions?
|
123
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
|