mindee 3.5.0 → 3.6.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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +2 -1
  4. data/bin/mindee.rb +6 -0
  5. data/docs/bank_account_details_v2.md +1 -1
  6. data/docs/bank_check_v1.md +1 -1
  7. data/docs/bank_statement_fr_v1.md +1 -1
  8. data/docs/barcode_reader_v1.md +1 -1
  9. data/docs/carte_grise_v1.md +1 -1
  10. data/docs/carte_vitale_v1.md +1 -1
  11. data/docs/code_samples/resume_v1_async.txt +19 -0
  12. data/docs/cropper_v1.md +1 -1
  13. data/docs/custom_v1.md +1 -1
  14. data/docs/eu_driver_license_v1.md +5 -5
  15. data/docs/expense_receipts_v5.md +1 -1
  16. data/docs/financial_document_v1.md +1 -1
  17. data/docs/generated_v1.md +1 -1
  18. data/docs/getting_started.md +1 -1
  19. data/docs/idcard_fr_v2.md +1 -1
  20. data/docs/international_id_v2.md +195 -0
  21. data/docs/invoice_splitter_v1.md +1 -1
  22. data/docs/invoices_v4.md +1 -1
  23. data/docs/license_plates_v1.md +1 -1
  24. data/docs/multi_receipts_detector_v1.md +1 -1
  25. data/docs/passport_v1.md +1 -1
  26. data/docs/proof_of_address_v1.md +1 -1
  27. data/docs/resume_v1.md +334 -0
  28. data/docs/us_driver_license_v1.md +1 -1
  29. data/docs/us_w9_v1.md +1 -1
  30. data/lib/mindee/parsing/standard/base_field.rb +1 -1
  31. data/lib/mindee/product/.rubocop.yml +7 -2
  32. data/lib/mindee/product/eu/driver_license/driver_license_v1.rb +2 -2
  33. data/lib/mindee/product/eu/driver_license/driver_license_v1_document.rb +1 -1
  34. data/lib/mindee/product/eu/driver_license/driver_license_v1_page.rb +2 -2
  35. data/lib/mindee/product/fr/carte_grise/carte_grise_v1_document.rb +0 -2
  36. data/lib/mindee/product/resume/resume_v1.rb +39 -0
  37. data/lib/mindee/product/resume/resume_v1_certificate.rb +69 -0
  38. data/lib/mindee/product/resume/resume_v1_document.rb +322 -0
  39. data/lib/mindee/product/resume/resume_v1_education.rb +90 -0
  40. data/lib/mindee/product/resume/resume_v1_language.rb +55 -0
  41. data/lib/mindee/product/resume/resume_v1_page.rb +32 -0
  42. data/lib/mindee/product/resume/resume_v1_professional_experience.rb +97 -0
  43. data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +55 -0
  44. data/lib/mindee/product.rb +1 -0
  45. data/lib/mindee/version.rb +1 -1
  46. metadata +13 -2
data/docs/resume_v1.md ADDED
@@ -0,0 +1,334 @@
1
+ ---
2
+ title: Resume OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [Resume API](https://platform.mindee.com/mindee/resume).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/resume/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
+ ![Resume sample](https://github.com/mindee/client-lib-test-data/blob/main/products/resume/default_sample.jpg?raw=true)
8
+
9
+ # Quick-Start
10
+ ```rb
11
+ require 'mindee'
12
+
13
+ # Init a new client
14
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
15
+
16
+ # Load a file from disk
17
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
18
+
19
+ # Parse the file
20
+ result = mindee_client.enqueue_and_parse(
21
+ input_source,
22
+ Mindee::Product::Resume::ResumeV1
23
+ )
24
+
25
+ # Print a full summary of the parsed data in RST format
26
+ puts result.document
27
+
28
+ # Print the document-level parsed data
29
+ # puts result.document.inference.prediction
30
+ ```
31
+
32
+ **Output (RST):**
33
+ ```rst
34
+ ########
35
+ Document
36
+ ########
37
+ :Mindee ID: bc80bae0-af75-4464-95a9-2419403c75bf
38
+ :Filename: default_sample.jpg
39
+
40
+ Inference
41
+ #########
42
+ :Product: mindee/resume v1.0
43
+ :Rotation applied: No
44
+
45
+ Prediction
46
+ ==========
47
+ :Document Language: ENG
48
+ :Document Type: RESUME
49
+ :Given Names: Christopher
50
+ :Surnames: Morgan
51
+ :Nationality:
52
+ :Email Address: christoper.m@gmail.com
53
+ :Phone Number: +44 (0) 20 7666 8555
54
+ :Address: 177 Great Portland Street, London W5W 6PQ
55
+ :Social Networks:
56
+ +----------------------+----------------------------------------------------+
57
+ | Name | URL |
58
+ +======================+====================================================+
59
+ | LinkedIn | linkedin.com/christopher.morgan |
60
+ +----------------------+----------------------------------------------------+
61
+ :Profession: Senior Web Developer
62
+ :Job Applied:
63
+ :Languages:
64
+ +----------+----------------------+
65
+ | Language | Level |
66
+ +==========+======================+
67
+ | SPA | Fluent |
68
+ +----------+----------------------+
69
+ | ZHO | Beginner |
70
+ +----------+----------------------+
71
+ | DEU | Intermediate |
72
+ +----------+----------------------+
73
+ :Hard Skills: HTML5
74
+ PHP OOP
75
+ JavaScript
76
+ CSS
77
+ MySQL
78
+ :Soft Skills: Project management
79
+ Strong decision maker
80
+ Innovative
81
+ Complex problem solver
82
+ Creative design
83
+ Service-focused
84
+ :Education:
85
+ +-----------------+---------------------------+-----------+----------+---------------------------+-------------+------------+
86
+ | Domain | Degree | End Month | End Year | School | Start Month | Start Year |
87
+ +=================+===========================+===========+==========+===========================+=============+============+
88
+ | Computer Inf... | Bachelor | | | Columbia University, NY | | 2014 |
89
+ +-----------------+---------------------------+-----------+----------+---------------------------+-------------+------------+
90
+ :Professional Experiences:
91
+ +-----------------+------------+---------------------------+-----------+----------+----------------------+-------------+------------+
92
+ | Contract Type | Department | Employer | End Month | End Year | Role | Start Month | Start Year |
93
+ +=================+============+===========================+===========+==========+======================+=============+============+
94
+ | Full-Time | | Luna Web Design, New York | 05 | 2019 | Web Developer | 09 | 2015 |
95
+ +-----------------+------------+---------------------------+-----------+----------+----------------------+-------------+------------+
96
+ :Certificates:
97
+ +------------+--------------------------------+---------------------------+------+
98
+ | Grade | Name | Provider | Year |
99
+ +============+================================+===========================+======+
100
+ | | PHP Framework (certificate)... | | 2014 |
101
+ +------------+--------------------------------+---------------------------+------+
102
+ | | Programming Languages: Java... | | |
103
+ +------------+--------------------------------+---------------------------+------+
104
+ ```
105
+
106
+ # Field Types
107
+ ## Standard Fields
108
+ These fields are generic and used in several products.
109
+
110
+ ### Basic Field
111
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
112
+ A typical `Field` object will have the following attributes:
113
+
114
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
115
+ * **confidence** (Float, nil): the confidence score of the field prediction.
116
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
117
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
118
+ * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
119
+ * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
120
+
121
+
122
+ 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.
123
+
124
+
125
+ ### Classification Field
126
+ The classification field `ClassificationField` does not implement all the basic `Field` attributes. It only implements **value**, **confidence** and **page_id**.
127
+
128
+ > Note: a classification field's `value is always a `String`.
129
+
130
+ ### String Field
131
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
132
+
133
+ ## Specific Fields
134
+ Fields which are specific to this product; they are not used in any other product.
135
+
136
+ ### Certificates Field
137
+ The list of certificates obtained by the candidate.
138
+
139
+ A `ResumeV1Certificate` implements the following attributes:
140
+
141
+ * `grade` (String): The grade obtained for the certificate.
142
+ * `name` (String): The name of certification.
143
+ * `provider` (String): The organization or institution that issued the certificate.
144
+ * `year` (String): The year when a certificate was issued or received.
145
+ Fields which are specific to this product; they are not used in any other product.
146
+
147
+ ### Education Field
148
+ The list of the candidate's educational background.
149
+
150
+ A `ResumeV1Education` implements the following attributes:
151
+
152
+ * `degree_domain` (String): The area of study or specialization.
153
+ * `degree_type` (String): The type of degree obtained, such as Bachelor's, Master's, or Doctorate.
154
+ * `end_month` (String): The month when the education program or course was completed.
155
+ * `end_year` (String): The year when the education program or course was completed.
156
+ * `school` (String): The name of the school.
157
+ * `start_month` (String): The month when the education program or course began.
158
+ * `start_year` (String): The year when the education program or course began.
159
+ Fields which are specific to this product; they are not used in any other product.
160
+
161
+ ### Languages Field
162
+ The list of languages that the candidate is proficient in.
163
+
164
+ A `ResumeV1Language` implements the following attributes:
165
+
166
+ * `language` (String): The language's ISO 639 code.
167
+ * `level` (String): The candidate's level for the language.
168
+ Fields which are specific to this product; they are not used in any other product.
169
+
170
+ ### Professional Experiences Field
171
+ The list of the candidate's professional experiences.
172
+
173
+ A `ResumeV1ProfessionalExperience` implements the following attributes:
174
+
175
+ * `contract_type` (String): The type of contract for the professional experience.
176
+ * `department` (String): The specific department or division within the company.
177
+ * `employer` (String): The name of the company or organization.
178
+ * `end_month` (String): The month when the professional experience ended.
179
+ * `end_year` (String): The year when the professional experience ended.
180
+ * `role` (String): The position or job title held by the candidate.
181
+ * `start_month` (String): The month when the professional experience began.
182
+ * `start_year` (String): The year when the professional experience began.
183
+ Fields which are specific to this product; they are not used in any other product.
184
+
185
+ ### Social Networks Field
186
+ The list of social network profiles of the candidate.
187
+
188
+ A `ResumeV1SocialNetworksUrl` implements the following attributes:
189
+
190
+ * `name` (String): The name of the social network.
191
+ * `url` (String): The URL of the social network.
192
+
193
+ # Attributes
194
+ The following fields are extracted for Resume V1:
195
+
196
+ ## Address
197
+ **address** ([StringField](#string-field)): The location information of the candidate, including city, state, and country.
198
+
199
+ ```rb
200
+ puts result.document.inference.prediction.address.value
201
+ ```
202
+
203
+ ## Certificates
204
+ **certificates** (Array<[ResumeV1Certificate](#certificates-field)>): The list of certificates obtained by the candidate.
205
+
206
+ ```rb
207
+ for certificates_elem in result.document.inference.prediction.certificates do
208
+ puts certificates_elem.value
209
+ end
210
+ ```
211
+
212
+ ## Document Language
213
+ **document_language** ([StringField](#string-field)): The ISO 639 code of the language in which the document is written.
214
+
215
+ ```rb
216
+ puts result.document.inference.prediction.document_language.value
217
+ ```
218
+
219
+ ## Document Type
220
+ **document_type** ([ClassificationField](#classification-field)): The type of the document sent.
221
+
222
+ ```rb
223
+ puts result.document.inference.prediction.document_type.value
224
+ ```
225
+
226
+ ## Education
227
+ **education** (Array<[ResumeV1Education](#education-field)>): The list of the candidate's educational background.
228
+
229
+ ```rb
230
+ for education_elem in result.document.inference.prediction.education do
231
+ puts education_elem.value
232
+ end
233
+ ```
234
+
235
+ ## Email Address
236
+ **email_address** ([StringField](#string-field)): The email address of the candidate.
237
+
238
+ ```rb
239
+ puts result.document.inference.prediction.email_address.value
240
+ ```
241
+
242
+ ## Given Names
243
+ **given_names** (Array<[StringField](#string-field)>): The candidate's first or given names.
244
+
245
+ ```rb
246
+ for given_names_elem in result.document.inference.prediction.given_names do
247
+ puts given_names_elem.value
248
+ end
249
+ ```
250
+
251
+ ## Hard Skills
252
+ **hard_skills** (Array<[StringField](#string-field)>): The list of the candidate's technical abilities and knowledge.
253
+
254
+ ```rb
255
+ for hard_skills_elem in result.document.inference.prediction.hard_skills do
256
+ puts hard_skills_elem.value
257
+ end
258
+ ```
259
+
260
+ ## Job Applied
261
+ **job_applied** ([StringField](#string-field)): The position that the candidate is applying for.
262
+
263
+ ```rb
264
+ puts result.document.inference.prediction.job_applied.value
265
+ ```
266
+
267
+ ## Languages
268
+ **languages** (Array<[ResumeV1Language](#languages-field)>): The list of languages that the candidate is proficient in.
269
+
270
+ ```rb
271
+ for languages_elem in result.document.inference.prediction.languages do
272
+ puts languages_elem.value
273
+ end
274
+ ```
275
+
276
+ ## Nationality
277
+ **nationality** ([StringField](#string-field)): The ISO 3166 code for the country of citizenship of the candidate.
278
+
279
+ ```rb
280
+ puts result.document.inference.prediction.nationality.value
281
+ ```
282
+
283
+ ## Phone Number
284
+ **phone_number** ([StringField](#string-field)): The phone number of the candidate.
285
+
286
+ ```rb
287
+ puts result.document.inference.prediction.phone_number.value
288
+ ```
289
+
290
+ ## Profession
291
+ **profession** ([StringField](#string-field)): The candidate's current profession.
292
+
293
+ ```rb
294
+ puts result.document.inference.prediction.profession.value
295
+ ```
296
+
297
+ ## Professional Experiences
298
+ **professional_experiences** (Array<[ResumeV1ProfessionalExperience](#professional-experiences-field)>): The list of the candidate's professional experiences.
299
+
300
+ ```rb
301
+ for professional_experiences_elem in result.document.inference.prediction.professional_experiences do
302
+ puts professional_experiences_elem.value
303
+ end
304
+ ```
305
+
306
+ ## Social Networks
307
+ **social_networks_urls** (Array<[ResumeV1SocialNetworksUrl](#social-networks-field)>): The list of social network profiles of the candidate.
308
+
309
+ ```rb
310
+ for social_networks_urls_elem in result.document.inference.prediction.social_networks_urls do
311
+ puts social_networks_urls_elem.value
312
+ end
313
+ ```
314
+
315
+ ## Soft Skills
316
+ **soft_skills** (Array<[StringField](#string-field)>): The list of the candidate's interpersonal and communication abilities.
317
+
318
+ ```rb
319
+ for soft_skills_elem in result.document.inference.prediction.soft_skills do
320
+ puts soft_skills_elem.value
321
+ end
322
+ ```
323
+
324
+ ## Surnames
325
+ **surnames** (Array<[StringField](#string-field)>): The candidate's last names.
326
+
327
+ ```rb
328
+ for surnames_elem in result.document.inference.prediction.surnames do
329
+ puts surnames_elem.value
330
+ end
331
+ ```
332
+
333
+ # Questions?
334
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -265,4 +265,4 @@ puts result.document.inference.prediction.weight.value
265
265
  ```
266
266
 
267
267
  # Questions?
268
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
268
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
data/docs/us_w9_v1.md CHANGED
@@ -204,4 +204,4 @@ end
204
204
  ```
205
205
 
206
206
  # Questions?
207
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
207
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -96,7 +96,7 @@ module Mindee
96
96
  return '' if in_str.nil?
97
97
  return in_str if max_col_size.nil?
98
98
 
99
- in_str.length < max_col_size ? in_str : "#{in_str[0..max_col_size - 4]}..."
99
+ in_str.length <= max_col_size ? in_str : "#{in_str[0..max_col_size - 4]}..."
100
100
  end
101
101
  end
102
102
  end
@@ -1,5 +1,10 @@
1
1
  inherit_from: ../../../.rubocop.yml
2
2
 
3
3
  Metrics/AbcSize:
4
- Max: 75
5
-
4
+ Enabled: false
5
+ Metrics/ClassLength:
6
+ Enabled: false
7
+ Metrics/CyclomaticComplexity:
8
+ Enabled: false
9
+ Metrics/PerceivedComplexity:
10
+ Enabled: false
@@ -7,9 +7,9 @@ require_relative 'driver_license_v1_page'
7
7
  module Mindee
8
8
  module Product
9
9
  module EU
10
- # EU Driver License module.
10
+ # Driver License module.
11
11
  module DriverLicense
12
- # EU Driver License V1 prediction inference.
12
+ # Driver License V1 prediction inference.
13
13
  class DriverLicenseV1 < Mindee::Parsing::Common::Inference
14
14
  @endpoint_name = 'eu_driver_license'
15
15
  @endpoint_version = '1'
@@ -6,7 +6,7 @@ module Mindee
6
6
  module Product
7
7
  module EU
8
8
  module DriverLicense
9
- # EU Driver License V1 document prediction.
9
+ # Driver License V1 document prediction.
10
10
  class DriverLicenseV1Document < Mindee::Parsing::Common::Prediction
11
11
  include Mindee::Parsing::Standard
12
12
  # EU driver license holders address
@@ -7,7 +7,7 @@ module Mindee
7
7
  module Product
8
8
  module EU
9
9
  module DriverLicense
10
- # EU Driver License V1 page.
10
+ # Driver License V1 page.
11
11
  class DriverLicenseV1Page < Mindee::Parsing::Common::Page
12
12
  # @param prediction [Hash]
13
13
  def initialize(prediction)
@@ -19,7 +19,7 @@ module Mindee
19
19
  end
20
20
  end
21
21
 
22
- # EU Driver License V1 page prediction.
22
+ # Driver License V1 page prediction.
23
23
  class DriverLicenseV1PagePrediction < DriverLicenseV1Document
24
24
  include Mindee::Parsing::Standard
25
25
 
@@ -133,7 +133,6 @@ module Mindee
133
133
  # @return [Mindee::Parsing::Standard::StringField]
134
134
  attr_reader :y6
135
135
 
136
- # rubocop:disable Metrics/AbcSize
137
136
  # @param prediction [Hash]
138
137
  # @param page_id [Integer, nil]
139
138
  def initialize(prediction, page_id)
@@ -227,7 +226,6 @@ module Mindee
227
226
  out_str << "\n:MRZ Line 2: #{@mrz2}".rstrip
228
227
  out_str[1..].to_s
229
228
  end
230
- # rubocop:enable Metrics/AbcSize
231
229
  end
232
230
  end
233
231
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'resume_v1_document'
5
+ require_relative 'resume_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ # Resume module.
10
+ module Resume
11
+ # Resume V1 prediction inference.
12
+ class ResumeV1 < Mindee::Parsing::Common::Inference
13
+ @endpoint_name = 'resume'
14
+ @endpoint_version = '1'
15
+
16
+ # @param prediction [Hash]
17
+ def initialize(prediction)
18
+ super
19
+ @prediction = ResumeV1Document.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(ResumeV1Page.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,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module Resume
8
+ # The list of certificates obtained by the candidate.
9
+ class ResumeV1Certificate < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # The grade obtained for the certificate.
12
+ # @return [String]
13
+ attr_reader :grade
14
+ # The name of certification.
15
+ # @return [String]
16
+ attr_reader :name
17
+ # The organization or institution that issued the certificate.
18
+ # @return [String]
19
+ attr_reader :provider
20
+ # The year when a certificate was issued or received.
21
+ # @return [String]
22
+ attr_reader :year
23
+
24
+ # @param prediction [Hash]
25
+ # @param page_id [Integer, nil]
26
+ def initialize(prediction, page_id)
27
+ super(prediction, page_id)
28
+ @grade = prediction['grade']
29
+ @name = prediction['name']
30
+ @provider = prediction['provider']
31
+ @year = prediction['year']
32
+ @page_id = page_id
33
+ end
34
+
35
+ # @return [Hash]
36
+ def printable_values
37
+ printable = {}
38
+ printable[:grade] = format_for_display(@grade, 10)
39
+ printable[:name] = format_for_display(@name, 30)
40
+ printable[:provider] = format_for_display(@provider, 25)
41
+ printable[:year] = format_for_display(@year, nil)
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('| %- 11s', printable[:grade])
50
+ out_str << format('| %- 31s', printable[:name])
51
+ out_str << format('| %- 26s', printable[:provider])
52
+ out_str << format('| %- 5s', printable[:year])
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 << "\n :Grade: #{printable[:grade]}"
61
+ out_str << "\n :Name: #{printable[:name]}"
62
+ out_str << "\n :Provider: #{printable[:provider]}"
63
+ out_str << "\n :Year: #{printable[:year]}"
64
+ out_str
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end