mindee 4.7.1 → 4.8.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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +6 -6
  4. data/Rakefile +1 -0
  5. data/lib/mindee/errors/mindee_http_error_v2.rb +23 -4
  6. data/lib/mindee/errors/mindee_http_unknown_error_v2.rb +18 -0
  7. data/lib/mindee/http/endpoint.rb +1 -0
  8. data/lib/mindee/input/sources/local_input_source.rb +9 -1
  9. data/lib/mindee/parsing/v2/error_item.rb +21 -0
  10. data/lib/mindee/parsing/v2/error_response.rb +18 -3
  11. data/lib/mindee/parsing/v2/inference_result.rb +4 -0
  12. data/lib/mindee/parsing/v2/rag_metadata.rb +17 -0
  13. data/lib/mindee/product.rb +0 -1
  14. data/lib/mindee/version.rb +1 -1
  15. data/mindee.gemspec +1 -0
  16. data/sig/mindee/errors/mindee_http_error_v2.rbs +4 -1
  17. data/sig/mindee/errors/mindee_http_unknown_error_v2.rbs +9 -0
  18. data/sig/mindee/http/endpoint.rbs +1 -0
  19. data/sig/mindee/input/sources/local_input_source.rbs +1 -1
  20. data/sig/mindee/parsing/v2/error_item.rbs +13 -0
  21. data/sig/mindee/parsing/v2/error_response.rbs +3 -0
  22. data/sig/mindee/parsing/v2/inference_result.rbs +1 -0
  23. data/sig/mindee/parsing/v2/rag_metadata.rbs +13 -0
  24. metadata +22 -47
  25. data/docs/advanced_file_operations.md +0 -109
  26. data/docs/code_samples/us_mail_v2_async.txt +0 -24
  27. data/docs/getting_started.md +0 -257
  28. data/docs/global_products/barcode_reader_v1.md +0 -125
  29. data/docs/global_products/bill_of_lading_v1.md +0 -276
  30. data/docs/global_products/business_card_v1.md +0 -194
  31. data/docs/global_products/cropper_v1.md +0 -123
  32. data/docs/global_products/delivery_notes_v1.md +0 -168
  33. data/docs/global_products/driver_license_v1.md +0 -212
  34. data/docs/global_products/expense_receipts_v5.md +0 -415
  35. data/docs/global_products/financial_document_v1.md +0 -615
  36. data/docs/global_products/international_id_v2.md +0 -264
  37. data/docs/global_products/invoice_splitter_v1.md +0 -127
  38. data/docs/global_products/invoices_v4.md +0 -576
  39. data/docs/global_products/multi_receipts_detector_v1.md +0 -131
  40. data/docs/global_products/nutrition_facts_v1.md +0 -399
  41. data/docs/global_products/passport_v1.md +0 -207
  42. data/docs/global_products/resume_v1.md +0 -384
  43. data/docs/global_products/universal.md +0 -113
  44. data/docs/global_products.md +0 -6
  45. data/docs/loading_a_document.md +0 -330
  46. data/docs/localized_products/bank_account_details_v2.md +0 -158
  47. data/docs/localized_products/bank_check_v1.md +0 -205
  48. data/docs/localized_products/bank_statement_fr_v2.md +0 -269
  49. data/docs/localized_products/carte_grise_v1.md +0 -475
  50. data/docs/localized_products/energy_bill_fra_v1.md +0 -342
  51. data/docs/localized_products/french_healthcard_v1.md +0 -142
  52. data/docs/localized_products/idcard_fr_v2.md +0 -284
  53. data/docs/localized_products/ind_passport_v1.md +0 -307
  54. data/docs/localized_products/payslip_fra_v3.md +0 -344
  55. data/docs/localized_products/us_healthcare_cards_v1.md +0 -258
  56. data/docs/localized_products/us_mail_v3.md +0 -152
  57. data/docs/localized_products.md +0 -6
  58. data/lib/mindee/product/us/us_mail/us_mail_v2.rb +0 -47
  59. data/lib/mindee/product/us/us_mail/us_mail_v2_document.rb +0 -105
  60. data/lib/mindee/product/us/us_mail/us_mail_v2_page.rb +0 -38
  61. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +0 -105
  62. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb +0 -63
  63. data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +0 -66
  64. data/sig/mindee/product/us/us_mail/us_mail_v2.rbs +0 -13
  65. data/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs +0 -20
  66. data/sig/mindee/product/us/us_mail/us_mail_v2_page.rbs +0 -17
  67. data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs +0 -22
  68. data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs +0 -15
  69. data/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs +0 -18
@@ -1,276 +0,0 @@
1
- ---
2
- title: Bill of Lading
3
- category: 622b805aaec68102ea7fcbc2
4
- slug: ruby-bill-of-lading-ocr
5
- parentDoc: 67b49df15b843f3fa9cd622b
6
- ---
7
- The Ruby Client Library supports the [Bill of Lading API](https://platform.mindee.com/mindee/bill_of_lading).
8
-
9
-
10
- > 📝 Product Specs
11
- >
12
- > | Specification | Details |
13
- > | ------------------------------ | -------------------------------------------------- |
14
- > | Endpoint Name | `bill_of_lading` |
15
- > | Recommended Version | `v1.1` |
16
- > | Supports Polling/Webhooks | ✔️ Yes |
17
- > | Support Synchronous HTTP Calls | ❌ No |
18
- > | Geography | 🌐 Global |
19
-
20
- > 🔐 Polling Limitations
21
- >
22
- > | Setting | Parameter name | Default Value |
23
- > | ------------------------------- | ----------------------- | ------------- |
24
- > | Initial Delay Before Polling | `initial_delay_seconds` | 2 seconds |
25
- > | Default Delay Between Calls | `delay_sec` | 1.5 seconds |
26
- > | Polling Attempts Before Timeout | `max_retries` | 80 retries |
27
-
28
-
29
- Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/bill_of_lading/default_sample.jpg),
30
- we are going to illustrate how to extract the data that we want using the Ruby Client Library.
31
- ![Bill of Lading sample](https://github.com/mindee/client-lib-test-data/blob/main/products/bill_of_lading/default_sample.jpg?raw=true)
32
-
33
- # Quick-Start
34
- ```rb
35
- #
36
- # Install the Ruby client library by running:
37
- # gem install mindee
38
- #
39
-
40
- require 'mindee'
41
-
42
- # Init a new client
43
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
44
-
45
- # Load a file from disk
46
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
47
-
48
- # Parse the file
49
- result = mindee_client.parse(
50
- input_source,
51
- Mindee::Product::BillOfLading::BillOfLadingV1
52
- )
53
-
54
- # Print a full summary of the parsed data in RST format
55
- puts result.document
56
-
57
- # Print the document-level parsed data
58
- # puts result.document.inference.prediction
59
- ```
60
-
61
- **Output (RST):**
62
- ```rst
63
- ########
64
- Document
65
- ########
66
- :Mindee ID: 3b5250a1-b52c-4e0b-bc3e-2f0146b04e29
67
- :Filename: default_sample.jpg
68
-
69
- Inference
70
- #########
71
- :Product: mindee/bill_of_lading v1.1
72
- :Rotation applied: No
73
-
74
- Prediction
75
- ==========
76
- :Bill of Lading Number: XYZ123456
77
- :Shipper:
78
- :Address: 123 OCEAN DRIVE, SHANGHAI, CHINA
79
- :Email:
80
- :Name: GLOBAL FREIGHT SOLUTIONS INC.
81
- :Phone: 86-21-12345678
82
- :Consignee:
83
- :Address: 789 TRADE STREET, SINGAPORE 567890, SINGAPORE
84
- :Email:
85
- :Name: PACIFIC TRADING CO.
86
- :Phone: 65-65432100
87
- :Notify Party:
88
- :Address: 789 TRADE STREET, SINGAPORE 567890, SINGAPORE
89
- :Email:
90
- :Name: PACIFIC TRADING CO.
91
- :Phone: 65-65432100
92
- :Carrier:
93
- :Name: GLOBAL SHIPPING CO.,LTD.
94
- :Professional Number:
95
- :SCAC:
96
- :Items:
97
- +--------------------------------------+--------------+-------------+------------------+----------+-------------+
98
- | Description | Gross Weight | Measurement | Measurement Unit | Quantity | Weight Unit |
99
- +======================================+==============+=============+==================+==========+=============+
100
- | ELECTRONIC COMPONENTS\nP/N: 12345... | 500.00 | 1.50 | cbm | 1.00 | kgs |
101
- +--------------------------------------+--------------+-------------+------------------+----------+-------------+
102
- :Port of Loading: SHANGHAI, CHINA
103
- :Port of Discharge: LOS ANGELES, USA
104
- :Place of Delivery: LOS ANGELES, USA
105
- :Date of issue: 2022-09-30
106
- :Departure Date:
107
- ```
108
-
109
- # Field Types
110
- ## Standard Fields
111
- These fields are generic and used in several products.
112
-
113
- ### Basic Field
114
- Each prediction object contains a set of fields that inherit from the generic `Field` class.
115
- A typical `Field` object will have the following attributes:
116
-
117
- * **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
118
- * **confidence** (Float, nil): the confidence score of the field prediction.
119
- * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
120
- * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
121
- * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
122
- * **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
123
-
124
-
125
- 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.
126
-
127
- ### Date Field
128
- Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
129
-
130
- * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
131
-
132
- ### String Field
133
- The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
134
-
135
- ## Specific Fields
136
- Fields which are specific to this product; they are not used in any other product.
137
-
138
- ### Shipper Field
139
- The party responsible for shipping the goods.
140
-
141
- A `BillOfLadingV1Shipper` implements the following attributes:
142
-
143
- * `address` (String): The address of the shipper.
144
- * `email` (String): The email of the shipper.
145
- * `name` (String): The name of the shipper.
146
- * `phone` (String): The phone number of the shipper.
147
- Fields which are specific to this product; they are not used in any other product.
148
-
149
- ### Consignee Field
150
- The party to whom the goods are being shipped.
151
-
152
- A `BillOfLadingV1Consignee` implements the following attributes:
153
-
154
- * `address` (String): The address of the consignee.
155
- * `email` (String): The email of the shipper.
156
- * `name` (String): The name of the consignee.
157
- * `phone` (String): The phone number of the consignee.
158
- Fields which are specific to this product; they are not used in any other product.
159
-
160
- ### Notify Party Field
161
- The party to be notified of the arrival of the goods.
162
-
163
- A `BillOfLadingV1NotifyParty` implements the following attributes:
164
-
165
- * `address` (String): The address of the notify party.
166
- * `email` (String): The email of the shipper.
167
- * `name` (String): The name of the notify party.
168
- * `phone` (String): The phone number of the notify party.
169
- Fields which are specific to this product; they are not used in any other product.
170
-
171
- ### Carrier Field
172
- The shipping company responsible for transporting the goods.
173
-
174
- A `BillOfLadingV1Carrier` implements the following attributes:
175
-
176
- * `name` (String): The name of the carrier.
177
- * `professional_number` (String): The professional number of the carrier.
178
- * `scac` (String): The Standard Carrier Alpha Code (SCAC) of the carrier.
179
- Fields which are specific to this product; they are not used in any other product.
180
-
181
- ### Items Field
182
- The goods being shipped.
183
-
184
- A `BillOfLadingV1CarrierItem` implements the following attributes:
185
-
186
- * `description` (String): A description of the item.
187
- * `gross_weight` (Float): The gross weight of the item.
188
- * `measurement` (Float): The measurement of the item.
189
- * `measurement_unit` (String): The unit of measurement for the measurement.
190
- * `quantity` (Float): The quantity of the item being shipped.
191
- * `weight_unit` (String): The unit of measurement for weights.
192
-
193
- # Attributes
194
- The following fields are extracted for Bill of Lading V1:
195
-
196
- ## Bill of Lading Number
197
- **bill_of_lading_number** ([StringField](#string-field)): A unique identifier assigned to a Bill of Lading document.
198
-
199
- ```rb
200
- puts result.document.inference.prediction.bill_of_lading_number.value
201
- ```
202
-
203
- ## Carrier
204
- **carrier** ([BillOfLadingV1Carrier](#carrier-field)): The shipping company responsible for transporting the goods.
205
-
206
- ```rb
207
- puts result.document.inference.prediction.carrier.value
208
- ```
209
-
210
- ## Items
211
- **carrier_items** (Array<[BillOfLadingV1CarrierItem](#items-field)>): The goods being shipped.
212
-
213
- ```rb
214
- result.document.inference.prediction.carrier_items do |carrier_items_elem|
215
- puts carrier_items_elem.value
216
- end
217
- ```
218
-
219
- ## Consignee
220
- **consignee** ([BillOfLadingV1Consignee](#consignee-field)): The party to whom the goods are being shipped.
221
-
222
- ```rb
223
- puts result.document.inference.prediction.consignee.value
224
- ```
225
-
226
- ## Date of issue
227
- **date_of_issue** ([DateField](#date-field)): The date when the bill of lading is issued.
228
-
229
- ```rb
230
- puts result.document.inference.prediction.date_of_issue.value
231
- ```
232
-
233
- ## Departure Date
234
- **departure_date** ([DateField](#date-field)): The date when the vessel departs from the port of loading.
235
-
236
- ```rb
237
- puts result.document.inference.prediction.departure_date.value
238
- ```
239
-
240
- ## Notify Party
241
- **notify_party** ([BillOfLadingV1NotifyParty](#notify-party-field)): The party to be notified of the arrival of the goods.
242
-
243
- ```rb
244
- puts result.document.inference.prediction.notify_party.value
245
- ```
246
-
247
- ## Place of Delivery
248
- **place_of_delivery** ([StringField](#string-field)): The place where the goods are to be delivered.
249
-
250
- ```rb
251
- puts result.document.inference.prediction.place_of_delivery.value
252
- ```
253
-
254
- ## Port of Discharge
255
- **port_of_discharge** ([StringField](#string-field)): The port where the goods are unloaded from the vessel.
256
-
257
- ```rb
258
- puts result.document.inference.prediction.port_of_discharge.value
259
- ```
260
-
261
- ## Port of Loading
262
- **port_of_loading** ([StringField](#string-field)): The port where the goods are loaded onto the vessel.
263
-
264
- ```rb
265
- puts result.document.inference.prediction.port_of_loading.value
266
- ```
267
-
268
- ## Shipper
269
- **shipper** ([BillOfLadingV1Shipper](#shipper-field)): The party responsible for shipping the goods.
270
-
271
- ```rb
272
- puts result.document.inference.prediction.shipper.value
273
- ```
274
-
275
- # Questions?
276
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -1,194 +0,0 @@
1
- ---
2
- title: Business Card
3
- category: 622b805aaec68102ea7fcbc2
4
- slug: ruby-business-card-ocr
5
- parentDoc: 67b49df15b843f3fa9cd622b
6
- ---
7
- The Ruby Client Library supports the [Business Card API](https://platform.mindee.com/mindee/business_card).
8
-
9
-
10
- > 📝 Product Specs
11
- >
12
- > | Specification | Details |
13
- > | ------------------------------ | -------------------------------------------------- |
14
- > | Endpoint Name | `business_card` |
15
- > | Recommended Version | `v1.0` |
16
- > | Supports Polling/Webhooks | ✔️ Yes |
17
- > | Support Synchronous HTTP Calls | ❌ No |
18
- > | Geography | 🌐 Global |
19
-
20
- > 🔐 Polling Limitations
21
- >
22
- > | Setting | Parameter name | Default Value |
23
- > | ------------------------------- | ----------------------- | ------------- |
24
- > | Initial Delay Before Polling | `initial_delay_seconds` | 2 seconds |
25
- > | Default Delay Between Calls | `delay_sec` | 1.5 seconds |
26
- > | Polling Attempts Before Timeout | `max_retries` | 80 retries |
27
-
28
-
29
- Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/business_card/default_sample.jpg),
30
- we are going to illustrate how to extract the data that we want using the Ruby Client Library.
31
- ![Business Card sample](https://github.com/mindee/client-lib-test-data/blob/main/products/business_card/default_sample.jpg?raw=true)
32
-
33
- # Quick-Start
34
- ```rb
35
- #
36
- # Install the Ruby client library by running:
37
- # gem install mindee
38
- #
39
-
40
- require 'mindee'
41
-
42
- # Init a new client
43
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
44
-
45
- # Load a file from disk
46
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
47
-
48
- # Parse the file
49
- result = mindee_client.parse(
50
- input_source,
51
- Mindee::Product::BusinessCard::BusinessCardV1
52
- )
53
-
54
- # Print a full summary of the parsed data in RST format
55
- puts result.document
56
-
57
- # Print the document-level parsed data
58
- # puts result.document.inference.prediction
59
- ```
60
-
61
- **Output (RST):**
62
- ```rst
63
- ########
64
- Document
65
- ########
66
- :Mindee ID: 6f9a261f-7609-4687-9af0-46a45156566e
67
- :Filename: default_sample.jpg
68
-
69
- Inference
70
- #########
71
- :Product: mindee/business_card v1.0
72
- :Rotation applied: Yes
73
-
74
- Prediction
75
- ==========
76
- :Firstname: Andrew
77
- :Lastname: Morin
78
- :Job Title: Founder & CEO
79
- :Company: RemoteGlobal
80
- :Email: amorin@remoteglobalconsulting.com
81
- :Phone Number: +14015555555
82
- :Mobile Number: +13015555555
83
- :Fax Number: +14015555556
84
- :Address: 178 Main Avenue, Providence, RI 02111
85
- :Website: www.remoteglobalconsulting.com
86
- :Social Media: https://www.linkedin.com/in/johndoe
87
- https://twitter.com/johndoe
88
- ```
89
-
90
- # Field Types
91
- ## Standard Fields
92
- These fields are generic and used in several products.
93
-
94
- ### Basic Field
95
- Each prediction object contains a set of fields that inherit from the generic `Field` class.
96
- A typical `Field` object will have the following attributes:
97
-
98
- * **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
99
- * **confidence** (Float, nil): the confidence score of the field prediction.
100
- * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
101
- * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
102
- * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
103
- * **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
104
-
105
-
106
- 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.
107
-
108
- ### String Field
109
- The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
110
-
111
- # Attributes
112
- The following fields are extracted for Business Card V1:
113
-
114
- ## Address
115
- **address** ([StringField](#string-field)): The address of the person.
116
-
117
- ```rb
118
- puts result.document.inference.prediction.address.value
119
- ```
120
-
121
- ## Company
122
- **company** ([StringField](#string-field)): The company the person works for.
123
-
124
- ```rb
125
- puts result.document.inference.prediction.company.value
126
- ```
127
-
128
- ## Email
129
- **email** ([StringField](#string-field)): The email address of the person.
130
-
131
- ```rb
132
- puts result.document.inference.prediction.email.value
133
- ```
134
-
135
- ## Fax Number
136
- **fax_number** ([StringField](#string-field)): The Fax number of the person.
137
-
138
- ```rb
139
- puts result.document.inference.prediction.fax_number.value
140
- ```
141
-
142
- ## Firstname
143
- **firstname** ([StringField](#string-field)): The given name of the person.
144
-
145
- ```rb
146
- puts result.document.inference.prediction.firstname.value
147
- ```
148
-
149
- ## Job Title
150
- **job_title** ([StringField](#string-field)): The job title of the person.
151
-
152
- ```rb
153
- puts result.document.inference.prediction.job_title.value
154
- ```
155
-
156
- ## Lastname
157
- **lastname** ([StringField](#string-field)): The lastname of the person.
158
-
159
- ```rb
160
- puts result.document.inference.prediction.lastname.value
161
- ```
162
-
163
- ## Mobile Number
164
- **mobile_number** ([StringField](#string-field)): The mobile number of the person.
165
-
166
- ```rb
167
- puts result.document.inference.prediction.mobile_number.value
168
- ```
169
-
170
- ## Phone Number
171
- **phone_number** ([StringField](#string-field)): The phone number of the person.
172
-
173
- ```rb
174
- puts result.document.inference.prediction.phone_number.value
175
- ```
176
-
177
- ## Social Media
178
- **social_media** (Array<[StringField](#string-field)>): The social media profiles of the person or company.
179
-
180
- ```rb
181
- result.document.inference.prediction.social_media do |social_media_elem|
182
- puts social_media_elem.value
183
- end
184
- ```
185
-
186
- ## Website
187
- **website** ([StringField](#string-field)): The website of the person or company.
188
-
189
- ```rb
190
- puts result.document.inference.prediction.website.value
191
- ```
192
-
193
- # Questions?
194
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -1,123 +0,0 @@
1
- ---
2
- title: Cropper
3
- category: 622b805aaec68102ea7fcbc2
4
- slug: ruby-cropper-ocr
5
- parentDoc: 67b49df15b843f3fa9cd622b
6
- ---
7
- The Ruby Client Library supports the [Cropper API](https://platform.mindee.com/mindee/cropper).
8
-
9
-
10
- > 📝 Product Specs
11
- >
12
- > | Specification | Details |
13
- > | ------------------------------ | -------------------------------------------------- |
14
- > | Endpoint Name | `cropper` |
15
- > | Recommended Version | `v1.1` |
16
- > | Supports Polling/Webhooks | ❌ No |
17
- > | Support Synchronous HTTP Calls | ✔️ Yes |
18
- > | Geography | 🌐 Global |
19
-
20
-
21
- Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/cropper/default_sample.jpg),
22
- we are going to illustrate how to extract the data that we want using the Ruby Client Library.
23
- ![Cropper sample](https://github.com/mindee/client-lib-test-data/blob/main/products/cropper/default_sample.jpg?raw=true)
24
-
25
- # Quick-Start
26
- ```rb
27
- #
28
- # Install the Ruby client library by running:
29
- # gem install mindee
30
- #
31
-
32
- require 'mindee'
33
-
34
- # Init a new client
35
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
36
-
37
- # Load a file from disk
38
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
39
-
40
- # Parse the file
41
- result = mindee_client.parse(
42
- input_source,
43
- Mindee::Product::Cropper::CropperV1
44
- )
45
-
46
- # Print a full summary of the parsed data in RST format
47
- puts result.document
48
- ```
49
-
50
- **Output (RST):**
51
- ```rst
52
- ########
53
- Document
54
- ########
55
- :Mindee ID: 149ce775-8302-4798-8649-7eda9fb84a1a
56
- :Filename: default_sample.jpg
57
-
58
- Inference
59
- #########
60
- :Product: mindee/cropper v1.0
61
- :Rotation applied: No
62
-
63
- Prediction
64
- ==========
65
-
66
- Page Predictions
67
- ================
68
-
69
- Page 0
70
- ------
71
- :Document Cropper: Polygon with 26 points.
72
- Polygon with 25 points.
73
- ```
74
-
75
- # Field Types
76
- ## Standard Fields
77
- These fields are generic and used in several products.
78
-
79
- ### Basic Field
80
- Each prediction object contains a set of fields that inherit from the generic `Field` class.
81
- A typical `Field` object will have the following attributes:
82
-
83
- * **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
84
- * **confidence** (Float, nil): the confidence score of the field prediction.
85
- * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
86
- * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
87
- * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
88
- * **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
89
-
90
-
91
- 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.
92
-
93
-
94
- ### Position Field
95
- The position field `PositionField` does not implement all the basic `Field` attributes, only **bounding_box**,
96
- **polygon** and **page_id**. On top of these, it has access to:
97
-
98
- * **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond
99
- canvas).
100
- * **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
101
-
102
- ## Page-Level Fields
103
- Some fields are constrained to the page level, and so will not be retrievable at document level.
104
-
105
- # Attributes
106
- The following fields are extracted for Cropper V1:
107
-
108
- ## Document Cropper
109
- [📄](#page-level-fields "This field is only present on individual pages.")**cropping** (Array<[PositionField](#position-field)>): List of documents found in the image.
110
-
111
- ```rb
112
- result.document.inference.pages do |page|
113
- page.prediction.cropping do |cropping_elem|
114
- puts cropping_elem.polygon.to_s
115
- puts cropping_elem.quadrangle.to_s
116
- puts cropping_elem.rectangle.to_s
117
- puts cropping_elem.boundingBox.to_s
118
- end
119
- end
120
- ```
121
-
122
- # Questions?
123
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)