mindee 3.15.0 → 3.16.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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/docs/business_card_v1.md +169 -0
  4. data/docs/code_samples/business_card_v1_async.txt +19 -0
  5. data/docs/code_samples/delivery_notes_v1_async.txt +19 -0
  6. data/docs/code_samples/expense_receipts_v5_async.txt +19 -0
  7. data/docs/code_samples/ind_passport_v1_async.txt +19 -0
  8. data/docs/delivery_notes_v1.md +143 -0
  9. data/docs/energy_bill_fra_v1.md +2 -2
  10. data/docs/expense_receipts_v5.md +27 -2
  11. data/docs/financial_document_v1.md +8 -4
  12. data/docs/ind_passport_v1.md +281 -0
  13. data/docs/invoices_v4.md +12 -8
  14. data/docs/resume_v1.md +17 -16
  15. data/lib/mindee/client.rb +8 -8
  16. data/lib/mindee/product/business_card/business_card_v1.rb +39 -0
  17. data/lib/mindee/product/business_card/business_card_v1_document.rb +85 -0
  18. data/lib/mindee/product/business_card/business_card_v1_page.rb +32 -0
  19. data/lib/mindee/product/delivery_note/delivery_note_v1.rb +39 -0
  20. data/lib/mindee/product/delivery_note/delivery_note_v1_document.rb +61 -0
  21. data/lib/mindee/product/delivery_note/delivery_note_v1_page.rb +32 -0
  22. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +1 -1
  23. data/lib/mindee/product/financial_document/financial_document_v1_page.rb +1 -1
  24. data/lib/mindee/product/ind/indian_passport/indian_passport_v1.rb +41 -0
  25. data/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb +143 -0
  26. data/lib/mindee/product/ind/indian_passport/indian_passport_v1_page.rb +34 -0
  27. data/lib/mindee/product/invoice/invoice_v4_document.rb +1 -1
  28. data/lib/mindee/product/invoice/invoice_v4_page.rb +1 -1
  29. data/lib/mindee/product/resume/resume_v1_document.rb +3 -1
  30. data/lib/mindee/product/resume/resume_v1_page.rb +1 -1
  31. data/lib/mindee/product/resume/resume_v1_professional_experience.rb +8 -0
  32. data/lib/mindee/product.rb +10 -7
  33. data/lib/mindee/version.rb +1 -1
  34. metadata +18 -2
@@ -0,0 +1,281 @@
1
+ ---
2
+ title: IND Passport - India OCR Ruby
3
+ category: 622b805aaec68102ea7fcbc2
4
+ slug: ruby-ind-passport---india-ocr
5
+ parentDoc: 6294d97ee723f1008d2ab28e
6
+ ---
7
+ The Ruby OCR SDK supports the [Passport - India API](https://platform.mindee.com/mindee/ind_passport).
8
+
9
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/ind_passport/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
10
+ ![Passport - India sample](https://github.com/mindee/client-lib-test-data/blob/main/products/ind_passport/default_sample.jpg?raw=true)
11
+
12
+ # Quick-Start
13
+ ```rb
14
+ require 'mindee'
15
+
16
+ # Init a new client
17
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
18
+
19
+ # Load a file from disk
20
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
21
+
22
+ # Parse the file
23
+ result = mindee_client.enqueue_and_parse(
24
+ input_source,
25
+ Mindee::Product::IND::IndianPassport::IndianPassportV1
26
+ )
27
+
28
+ # Print a full summary of the parsed data in RST format
29
+ puts result.document
30
+
31
+ # Print the document-level parsed data
32
+ # puts result.document.inference.prediction
33
+
34
+ ```
35
+
36
+ **Output (RST):**
37
+ ```rst
38
+ ########
39
+ Document
40
+ ########
41
+ :Mindee ID: cf88fd43-eaa1-497a-ba29-a9569a4edaa7
42
+ :Filename: default_sample.jpg
43
+
44
+ Inference
45
+ #########
46
+ :Product: mindee/ind_passport v1.0
47
+ :Rotation applied: Yes
48
+
49
+ Prediction
50
+ ==========
51
+ :Page Number: 1
52
+ :Country: IND
53
+ :ID Number: J8369854
54
+ :Given Names: JOCELYN MICHELLE
55
+ :Surname: DOE
56
+ :Birth Date: 1959-09-23
57
+ :Birth Place: GUNDUGOLANU
58
+ :Issuance Place: HYDERABAD
59
+ :Gender: F
60
+ :Issuance Date: 2011-10-11
61
+ :Expiry Date: 2021-10-10
62
+ :MRZ Line 1: P<DOE<<JOCELYNMICHELLE<<<<<<<<<<<<<<<<<<<<<
63
+ :MRZ Line 2: J8369854<4IND5909234F2110101<<<<<<<<<<<<<<<8
64
+ :Legal Guardian:
65
+ :Name of Spouse:
66
+ :Name of Mother:
67
+ :Old Passport Date of Issue:
68
+ :Old Passport Number:
69
+ :Address Line 1:
70
+ :Address Line 2:
71
+ :Address Line 3:
72
+ :Old Passport Place of Issue:
73
+ :File Number:
74
+ ```
75
+
76
+ # Field Types
77
+ ## Standard Fields
78
+ These fields are generic and used in several products.
79
+
80
+ ### Basic Field
81
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
82
+ A typical `Field` object will have the following attributes:
83
+
84
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
85
+ * **confidence** (Float, nil): the confidence score of the field prediction.
86
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
87
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
88
+ * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
89
+ * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
90
+
91
+
92
+ Aside from the previous attributes, all basic fields have access to a `to_s` method that can be used to print their value as a string.
93
+
94
+
95
+ ### Classification Field
96
+ The classification field `ClassificationField` does not implement all the basic `Field` attributes. It only implements **value**, **confidence** and **page_id**.
97
+
98
+ > Note: a classification field's `value is always a `String`.
99
+
100
+ ### Date Field
101
+ Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
102
+
103
+ * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
104
+
105
+ ### String Field
106
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
107
+
108
+ # Attributes
109
+ The following fields are extracted for Passport - India V1:
110
+
111
+ ## Address Line 1
112
+ **address1** ([StringField](#string-field)): The first line of the address of the passport holder.
113
+
114
+ ```rb
115
+ puts result.document.inference.prediction.address1.value
116
+ ```
117
+
118
+ ## Address Line 2
119
+ **address2** ([StringField](#string-field)): The second line of the address of the passport holder.
120
+
121
+ ```rb
122
+ puts result.document.inference.prediction.address2.value
123
+ ```
124
+
125
+ ## Address Line 3
126
+ **address3** ([StringField](#string-field)): The third line of the address of the passport holder.
127
+
128
+ ```rb
129
+ puts result.document.inference.prediction.address3.value
130
+ ```
131
+
132
+ ## Birth Date
133
+ **birth_date** ([DateField](#date-field)): The birth date of the passport holder, ISO format: YYYY-MM-DD.
134
+
135
+ ```rb
136
+ puts result.document.inference.prediction.birth_date.value
137
+ ```
138
+
139
+ ## Birth Place
140
+ **birth_place** ([StringField](#string-field)): The birth place of the passport holder.
141
+
142
+ ```rb
143
+ puts result.document.inference.prediction.birth_place.value
144
+ ```
145
+
146
+ ## Country
147
+ **country** ([StringField](#string-field)): ISO 3166-1 alpha-3 country code (3 letters format).
148
+
149
+ ```rb
150
+ puts result.document.inference.prediction.country.value
151
+ ```
152
+
153
+ ## Expiry Date
154
+ **expiry_date** ([DateField](#date-field)): The date when the passport will expire, ISO format: YYYY-MM-DD.
155
+
156
+ ```rb
157
+ puts result.document.inference.prediction.expiry_date.value
158
+ ```
159
+
160
+ ## File Number
161
+ **file_number** ([StringField](#string-field)): The file number of the passport document.
162
+
163
+ ```rb
164
+ puts result.document.inference.prediction.file_number.value
165
+ ```
166
+
167
+ ## Gender
168
+ **gender** ([ClassificationField](#classification-field)): The gender of the passport holder.
169
+
170
+ #### Possible values include:
171
+ - M
172
+ - F
173
+
174
+ ```rb
175
+ puts result.document.inference.prediction.gender.value
176
+ ```
177
+
178
+ ## Given Names
179
+ **given_names** ([StringField](#string-field)): The given names of the passport holder.
180
+
181
+ ```rb
182
+ puts result.document.inference.prediction.given_names.value
183
+ ```
184
+
185
+ ## ID Number
186
+ **id_number** ([StringField](#string-field)): The identification number of the passport document.
187
+
188
+ ```rb
189
+ puts result.document.inference.prediction.id_number.value
190
+ ```
191
+
192
+ ## Issuance Date
193
+ **issuance_date** ([DateField](#date-field)): The date when the passport was issued, ISO format: YYYY-MM-DD.
194
+
195
+ ```rb
196
+ puts result.document.inference.prediction.issuance_date.value
197
+ ```
198
+
199
+ ## Issuance Place
200
+ **issuance_place** ([StringField](#string-field)): The place where the passport was issued.
201
+
202
+ ```rb
203
+ puts result.document.inference.prediction.issuance_place.value
204
+ ```
205
+
206
+ ## Legal Guardian
207
+ **legal_guardian** ([StringField](#string-field)): The name of the legal guardian of the passport holder (if applicable).
208
+
209
+ ```rb
210
+ puts result.document.inference.prediction.legal_guardian.value
211
+ ```
212
+
213
+ ## MRZ Line 1
214
+ **mrz1** ([StringField](#string-field)): The first line of the machine-readable zone (MRZ) of the passport document.
215
+
216
+ ```rb
217
+ puts result.document.inference.prediction.mrz1.value
218
+ ```
219
+
220
+ ## MRZ Line 2
221
+ **mrz2** ([StringField](#string-field)): The second line of the machine-readable zone (MRZ) of the passport document.
222
+
223
+ ```rb
224
+ puts result.document.inference.prediction.mrz2.value
225
+ ```
226
+
227
+ ## Name of Mother
228
+ **name_of_mother** ([StringField](#string-field)): The name of the mother of the passport holder.
229
+
230
+ ```rb
231
+ puts result.document.inference.prediction.name_of_mother.value
232
+ ```
233
+
234
+ ## Name of Spouse
235
+ **name_of_spouse** ([StringField](#string-field)): The name of the spouse of the passport holder (if applicable).
236
+
237
+ ```rb
238
+ puts result.document.inference.prediction.name_of_spouse.value
239
+ ```
240
+
241
+ ## Old Passport Date of Issue
242
+ **old_passport_date_of_issue** ([DateField](#date-field)): The date of issue of the old passport (if applicable), ISO format: YYYY-MM-DD.
243
+
244
+ ```rb
245
+ puts result.document.inference.prediction.old_passport_date_of_issue.value
246
+ ```
247
+
248
+ ## Old Passport Number
249
+ **old_passport_number** ([StringField](#string-field)): The number of the old passport (if applicable).
250
+
251
+ ```rb
252
+ puts result.document.inference.prediction.old_passport_number.value
253
+ ```
254
+
255
+ ## Old Passport Place of Issue
256
+ **old_passport_place_of_issue** ([StringField](#string-field)): The place of issue of the old passport (if applicable).
257
+
258
+ ```rb
259
+ puts result.document.inference.prediction.old_passport_place_of_issue.value
260
+ ```
261
+
262
+ ## Page Number
263
+ **page_number** ([ClassificationField](#classification-field)): The page number of the passport document.
264
+
265
+ #### Possible values include:
266
+ - 1
267
+ - 2
268
+
269
+ ```rb
270
+ puts result.document.inference.prediction.page_number.value
271
+ ```
272
+
273
+ ## Surname
274
+ **surname** ([StringField](#string-field)): The surname of the passport holder.
275
+
276
+ ```rb
277
+ puts result.document.inference.prediction.surname.value
278
+ ```
279
+
280
+ # Questions?
281
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
data/docs/invoices_v4.md CHANGED
@@ -63,21 +63,23 @@ puts result.document
63
63
  ########
64
64
  Document
65
65
  ########
66
- :Mindee ID: 372d9d08-59d8-4e1c-9622-06648c1c238b
66
+ :Mindee ID: a67b70ea-4b1e-4eac-ae75-dda47a7064ae
67
67
  :Filename: default_sample.jpg
68
68
 
69
69
  Inference
70
70
  #########
71
- :Product: mindee/invoices v4.7
71
+ :Product: mindee/invoices v4.9
72
72
  :Rotation applied: Yes
73
73
 
74
74
  Prediction
75
75
  ==========
76
- :Locale: en; en; CAD;
76
+ :Locale: en-CA; en; CA; CAD;
77
77
  :Invoice Number: 14
78
+ :Purchase Order Number: AD29094
78
79
  :Reference Numbers: AD29094
79
80
  :Purchase Date: 2018-09-25
80
- :Due Date:
81
+ :Due Date: 2011-12-01
82
+ :Payment Date: 2011-12-01
81
83
  :Total Net: 2145.00
82
84
  :Total Amount: 2608.20
83
85
  :Total Tax: 193.20
@@ -93,7 +95,7 @@ Prediction
93
95
  :Supplier Address: 156 University Ave, Toronto ON, Canada, M5H 2H7
94
96
  :Supplier Phone Number: 4165551212
95
97
  :Supplier Website:
96
- :Supplier Email: ldoi@example.com
98
+ :Supplier Email: j_coi@example.com
97
99
  :Customer Name: JIRO DOI
98
100
  :Customer Company Registrations:
99
101
  :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
@@ -117,11 +119,13 @@ Page Predictions
117
119
 
118
120
  Page 0
119
121
  ------
120
- :Locale: en; en; CAD;
122
+ :Locale: en-CA; en; CA; CAD;
121
123
  :Invoice Number: 14
124
+ :Purchase Order Number: AD29094
122
125
  :Reference Numbers: AD29094
123
126
  :Purchase Date: 2018-09-25
124
- :Due Date:
127
+ :Due Date: 2011-12-01
128
+ :Payment Date: 2011-12-01
125
129
  :Total Net: 2145.00
126
130
  :Total Amount: 2608.20
127
131
  :Total Tax: 193.20
@@ -137,7 +141,7 @@ Page 0
137
141
  :Supplier Address: 156 University Ave, Toronto ON, Canada, M5H 2H7
138
142
  :Supplier Phone Number: 4165551212
139
143
  :Supplier Website:
140
- :Supplier Email: ldoi@example.com
144
+ :Supplier Email: j_coi@example.com
141
145
  :Customer Name: JIRO DOI
142
146
  :Customer Company Registrations:
143
147
  :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
data/docs/resume_v1.md CHANGED
@@ -38,13 +38,13 @@ puts result.document
38
38
  ########
39
39
  Document
40
40
  ########
41
- :Mindee ID: bc80bae0-af75-4464-95a9-2419403c75bf
41
+ :Mindee ID: 9daa3085-152c-454e-9245-636f13fc9dc3
42
42
  :Filename: default_sample.jpg
43
43
 
44
44
  Inference
45
45
  #########
46
- :Product: mindee/resume v1.0
47
- :Rotation applied: No
46
+ :Product: mindee/resume v1.1
47
+ :Rotation applied: Yes
48
48
 
49
49
  Prediction
50
50
  ==========
@@ -54,8 +54,8 @@ Prediction
54
54
  :Surnames: Morgan
55
55
  :Nationality:
56
56
  :Email Address: christoper.m@gmail.com
57
- :Phone Number: +44 (0) 20 7666 8555
58
- :Address: 177 Great Portland Street, London W5W 6PQ
57
+ :Phone Number: +44 (0)20 7666 8555
58
+ :Address: 177 Great Portland Street, London, W5W 6PQ
59
59
  :Social Networks:
60
60
  +----------------------+----------------------------------------------------+
61
61
  | Name | URL |
@@ -72,38 +72,37 @@ Prediction
72
72
  +----------+----------------------+
73
73
  | ZHO | Beginner |
74
74
  +----------+----------------------+
75
- | DEU | Intermediate |
75
+ | DEU | Beginner |
76
76
  +----------+----------------------+
77
77
  :Hard Skills: HTML5
78
78
  PHP OOP
79
79
  JavaScript
80
80
  CSS
81
81
  MySQL
82
+ SQL
82
83
  :Soft Skills: Project management
84
+ Creative design
83
85
  Strong decision maker
84
86
  Innovative
85
87
  Complex problem solver
86
- Creative design
87
88
  Service-focused
88
89
  :Education:
89
90
  +-----------------+---------------------------+-----------+----------+---------------------------+-------------+------------+
90
91
  | Domain | Degree | End Month | End Year | School | Start Month | Start Year |
91
92
  +=================+===========================+===========+==========+===========================+=============+============+
92
- | Computer Inf... | Bachelor | | | Columbia University, NY | | 2014 |
93
+ | Computer Inf... | Bachelor | | 2014 | Columbia University, NY | | |
93
94
  +-----------------+---------------------------+-----------+----------+---------------------------+-------------+------------+
94
95
  :Professional Experiences:
95
- +-----------------+------------+---------------------------+-----------+----------+----------------------+-------------+------------+
96
- | Contract Type | Department | Employer | End Month | End Year | Role | Start Month | Start Year |
97
- +=================+============+===========================+===========+==========+======================+=============+============+
98
- | Full-Time | | Luna Web Design, New York | 05 | 2019 | Web Developer | 09 | 2015 |
99
- +-----------------+------------+---------------------------+-----------+----------+----------------------+-------------+------------+
96
+ +-----------------+------------+--------------------------------------+---------------------------+-----------+----------+----------------------+-------------+------------+
97
+ | Contract Type | Department | Description | Employer | End Month | End Year | Role | Start Month | Start Year |
98
+ +=================+============+======================================+===========================+===========+==========+======================+=============+============+
99
+ | | | Cooperate with designers to creat... | Luna Web Design, New York | 05 | 2019 | Web Developer | 09 | 2015 |
100
+ +-----------------+------------+--------------------------------------+---------------------------+-----------+----------+----------------------+-------------+------------+
100
101
  :Certificates:
101
102
  +------------+--------------------------------+---------------------------+------+
102
103
  | Grade | Name | Provider | Year |
103
104
  +============+================================+===========================+======+
104
- | | PHP Framework (certificate)... | | 2014 |
105
- +------------+--------------------------------+---------------------------+------+
106
- | | Programming Languages: Java... | | |
105
+ | | PHP Framework (certificate)... | | |
107
106
  +------------+--------------------------------+---------------------------+------+
108
107
  ```
109
108
 
@@ -171,6 +170,7 @@ A `ResumeV1Language` implements the following attributes:
171
170
  * `level` (String): The candidate's level for the language.
172
171
 
173
172
  #### Possible values include:
173
+ - Native
174
174
  - Fluent
175
175
  - Proficient
176
176
  - Intermediate
@@ -192,6 +192,7 @@ A `ResumeV1ProfessionalExperience` implements the following attributes:
192
192
  - Freelance
193
193
 
194
194
  * `department` (String): The specific department or division within the company.
195
+ * `description` (String): The description of the professional experience as written in the document.
195
196
  * `employer` (String): The name of the company or organization.
196
197
  * `end_month` (String): The month when the professional experience ended.
197
198
  * `end_year` (String): The year when the professional experience ended.
data/lib/mindee/client.rb CHANGED
@@ -149,8 +149,8 @@ module Mindee
149
149
  # * `:on_min_pages` Apply the operation only if document has at least this many pages.
150
150
  # @param cropper [Boolean, nil] Whether to include cropper results for each page.
151
151
  # This performs a cropping operation on the server and will increase response time.
152
- # @param initial_delay_sec [Integer, Float] initial delay before polling. Defaults to 4.
153
- # @param delay_sec [Integer, Float] delay between polling attempts. Defaults to 2.
152
+ # @param initial_delay_sec [Integer, Float] initial delay before polling. Defaults to 2.
153
+ # @param delay_sec [Integer, Float] delay between polling attempts. Defaults to 1.5.
154
154
  # @param max_retries [Integer] maximum amount of retries. Defaults to 60.
155
155
  # @return [Mindee::Parsing::Common::ApiResponse]
156
156
  def enqueue_and_parse(
@@ -162,8 +162,8 @@ module Mindee
162
162
  close_file: true,
163
163
  page_options: nil,
164
164
  cropper: false,
165
- initial_delay_sec: 4,
166
- delay_sec: 2,
165
+ initial_delay_sec: 2,
166
+ delay_sec: 1.5,
167
167
  max_retries: 60
168
168
  )
169
169
  enqueue_res = enqueue(
@@ -272,13 +272,13 @@ module Mindee
272
272
  # @param max_retries [Integer, nil] maximum amount of retries.
273
273
  def validate_async_params(initial_delay_sec, delay_sec, max_retries)
274
274
  min_delay_sec = 1
275
- min_initial_delay_sec = 2
275
+ min_initial_delay_sec = 1
276
276
  min_retries = 2
277
- raise "Cannot set auto-poll delay to less than #{min_delay_sec} seconds" if delay_sec < min_delay_sec
277
+ raise "Cannot set auto-poll delay to less than #{min_delay_sec} second(s)" if delay_sec < min_delay_sec
278
278
  if initial_delay_sec < min_initial_delay_sec
279
- raise "Cannot set initial parsing delay to less than #{min_initial_delay_sec} seconds"
279
+ raise "Cannot set initial parsing delay to less than #{min_initial_delay_sec} second(s)"
280
280
  end
281
- raise "Cannot set auto-poll delay to less than #{min_retries} seconds" if max_retries < min_retries
281
+ raise "Cannot set auto-poll retries to less than #{min_retries}" if max_retries < min_retries
282
282
  end
283
283
 
284
284
  # Creates an endpoint with the given values. Raises an error if the endpoint is invalid.
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'business_card_v1_document'
5
+ require_relative 'business_card_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ # Business Card module.
10
+ module BusinessCard
11
+ # Business Card API version 1 inference prediction.
12
+ class BusinessCardV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'business_card'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = BusinessCardV1Document.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(BusinessCardV1Page.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,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module BusinessCard
8
+ # Business Card API version 1.0 document data.
9
+ class BusinessCardV1Document < Mindee::Parsing::Common::Prediction
10
+ include Mindee::Parsing::Standard
11
+ # The address of the person.
12
+ # @return [Mindee::Parsing::Standard::StringField]
13
+ attr_reader :address
14
+ # The company the person works for.
15
+ # @return [Mindee::Parsing::Standard::StringField]
16
+ attr_reader :company
17
+ # The email address of the person.
18
+ # @return [Mindee::Parsing::Standard::StringField]
19
+ attr_reader :email
20
+ # The Fax number of the person.
21
+ # @return [Mindee::Parsing::Standard::StringField]
22
+ attr_reader :fax_number
23
+ # The given name of the person.
24
+ # @return [Mindee::Parsing::Standard::StringField]
25
+ attr_reader :firstname
26
+ # The job title of the person.
27
+ # @return [Mindee::Parsing::Standard::StringField]
28
+ attr_reader :job_title
29
+ # The lastname of the person.
30
+ # @return [Mindee::Parsing::Standard::StringField]
31
+ attr_reader :lastname
32
+ # The mobile number of the person.
33
+ # @return [Mindee::Parsing::Standard::StringField]
34
+ attr_reader :mobile_number
35
+ # The phone number of the person.
36
+ # @return [Mindee::Parsing::Standard::StringField]
37
+ attr_reader :phone_number
38
+ # The social media profiles of the person or company.
39
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
40
+ attr_reader :social_media
41
+ # The website of the person or company.
42
+ # @return [Mindee::Parsing::Standard::StringField]
43
+ attr_reader :website
44
+
45
+ # @param prediction [Hash]
46
+ # @param page_id [Integer, nil]
47
+ def initialize(prediction, page_id)
48
+ super()
49
+ @address = StringField.new(prediction['address'], page_id)
50
+ @company = StringField.new(prediction['company'], page_id)
51
+ @email = StringField.new(prediction['email'], page_id)
52
+ @fax_number = StringField.new(prediction['fax_number'], page_id)
53
+ @firstname = StringField.new(prediction['firstname'], page_id)
54
+ @job_title = StringField.new(prediction['job_title'], page_id)
55
+ @lastname = StringField.new(prediction['lastname'], page_id)
56
+ @mobile_number = StringField.new(prediction['mobile_number'], page_id)
57
+ @phone_number = StringField.new(prediction['phone_number'], page_id)
58
+ @social_media = []
59
+ prediction['social_media'].each do |item|
60
+ @social_media.push(StringField.new(item, page_id))
61
+ end
62
+ @website = StringField.new(prediction['website'], page_id)
63
+ end
64
+
65
+ # @return [String]
66
+ def to_s
67
+ social_media = @social_media.join("\n #{' ' * 14}")
68
+ out_str = String.new
69
+ out_str << "\n:Firstname: #{@firstname}".rstrip
70
+ out_str << "\n:Lastname: #{@lastname}".rstrip
71
+ out_str << "\n:Job Title: #{@job_title}".rstrip
72
+ out_str << "\n:Company: #{@company}".rstrip
73
+ out_str << "\n:Email: #{@email}".rstrip
74
+ out_str << "\n:Phone Number: #{@phone_number}".rstrip
75
+ out_str << "\n:Mobile Number: #{@mobile_number}".rstrip
76
+ out_str << "\n:Fax Number: #{@fax_number}".rstrip
77
+ out_str << "\n:Address: #{@address}".rstrip
78
+ out_str << "\n:Website: #{@website}".rstrip
79
+ out_str << "\n:Social Media: #{social_media}".rstrip
80
+ out_str[1..].to_s
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'business_card_v1_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module BusinessCard
9
+ # Business Card API version 1.0 page data.
10
+ class BusinessCardV1Page < Mindee::Parsing::Common::Page
11
+ # @param prediction [Hash]
12
+ def initialize(prediction)
13
+ super(prediction)
14
+ @prediction = BusinessCardV1PagePrediction.new(
15
+ prediction['prediction'],
16
+ prediction['id']
17
+ )
18
+ end
19
+ end
20
+
21
+ # Business Card V1 page prediction.
22
+ class BusinessCardV1PagePrediction < BusinessCardV1Document
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,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'delivery_note_v1_document'
5
+ require_relative 'delivery_note_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ # Delivery note module.
10
+ module DeliveryNote
11
+ # Delivery note API version 1 inference prediction.
12
+ class DeliveryNoteV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'delivery_notes'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = DeliveryNoteV1Document.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(DeliveryNoteV1Page.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