mindee 4.7.2 β 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +6 -6
- data/Rakefile +1 -0
- data/lib/mindee/errors/mindee_http_error_v2.rb +23 -4
- data/lib/mindee/errors/mindee_http_unknown_error_v2.rb +18 -0
- data/lib/mindee/http/endpoint.rb +1 -0
- data/lib/mindee/parsing/v2/error_item.rb +21 -0
- data/lib/mindee/parsing/v2/error_response.rb +18 -3
- data/lib/mindee/parsing/v2/inference_result.rb +4 -0
- data/lib/mindee/parsing/v2/rag_metadata.rb +17 -0
- data/lib/mindee/version.rb +1 -1
- data/mindee.gemspec +1 -0
- data/sig/mindee/errors/mindee_http_error_v2.rbs +4 -1
- data/sig/mindee/errors/mindee_http_unknown_error_v2.rbs +9 -0
- data/sig/mindee/http/endpoint.rbs +1 -0
- data/sig/mindee/parsing/v2/error_item.rbs +13 -0
- data/sig/mindee/parsing/v2/error_response.rbs +3 -0
- data/sig/mindee/parsing/v2/inference_result.rbs +1 -0
- data/sig/mindee/parsing/v2/rag_metadata.rbs +13 -0
- metadata +22 -34
- data/docs/advanced_file_operations.md +0 -109
- data/docs/getting_started.md +0 -257
- data/docs/global_products/barcode_reader_v1.md +0 -125
- data/docs/global_products/bill_of_lading_v1.md +0 -276
- data/docs/global_products/business_card_v1.md +0 -194
- data/docs/global_products/cropper_v1.md +0 -123
- data/docs/global_products/delivery_notes_v1.md +0 -168
- data/docs/global_products/driver_license_v1.md +0 -212
- data/docs/global_products/expense_receipts_v5.md +0 -415
- data/docs/global_products/financial_document_v1.md +0 -615
- data/docs/global_products/international_id_v2.md +0 -264
- data/docs/global_products/invoice_splitter_v1.md +0 -127
- data/docs/global_products/invoices_v4.md +0 -576
- data/docs/global_products/multi_receipts_detector_v1.md +0 -131
- data/docs/global_products/nutrition_facts_v1.md +0 -399
- data/docs/global_products/passport_v1.md +0 -207
- data/docs/global_products/resume_v1.md +0 -384
- data/docs/global_products/universal.md +0 -113
- data/docs/global_products.md +0 -6
- data/docs/loading_a_document.md +0 -330
- data/docs/localized_products/bank_account_details_v2.md +0 -158
- data/docs/localized_products/bank_check_v1.md +0 -205
- data/docs/localized_products/bank_statement_fr_v2.md +0 -269
- data/docs/localized_products/carte_grise_v1.md +0 -475
- data/docs/localized_products/energy_bill_fra_v1.md +0 -342
- data/docs/localized_products/french_healthcard_v1.md +0 -142
- data/docs/localized_products/idcard_fr_v2.md +0 -284
- data/docs/localized_products/ind_passport_v1.md +0 -307
- data/docs/localized_products/payslip_fra_v3.md +0 -344
- data/docs/localized_products/us_healthcare_cards_v1.md +0 -258
- data/docs/localized_products/us_mail_v3.md +0 -152
- data/docs/localized_products.md +0 -6
data/docs/getting_started.md
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Getting Started
|
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
|
4
|
-
slug: ruby-getting-started
|
|
5
|
-
parentDoc: 6294d97ee723f1008d2ab28e
|
|
6
|
-
---
|
|
7
|
-
> π This guide will help you get the most out of the Mindee Ruby client library to easily extract data from your documents.
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
### Requirements
|
|
12
|
-
The following Ruby versions are tested and supported: 3.0, 3.1, 3.2, 3.3
|
|
13
|
-
|
|
14
|
-
### Standard Installation
|
|
15
|
-
To quickly get started with the Ruby Client Library, Install by adding this line to your application's Gemfile:
|
|
16
|
-
|
|
17
|
-
```shell
|
|
18
|
-
gem 'mindee'
|
|
19
|
-
```
|
|
20
|
-
And then execute:
|
|
21
|
-
|
|
22
|
-
```shell
|
|
23
|
-
bundle install
|
|
24
|
-
```
|
|
25
|
-
Or you can install it like this:
|
|
26
|
-
|
|
27
|
-
```shell
|
|
28
|
-
gem install mindee
|
|
29
|
-
```
|
|
30
|
-
Finally, Ruby away!
|
|
31
|
-
|
|
32
|
-
### Development Installation
|
|
33
|
-
If you'll be modifying the source code, you'll need to install the required libraries to get started.
|
|
34
|
-
|
|
35
|
-
We recommend using [Bundler](https://bundler.io/).
|
|
36
|
-
|
|
37
|
-
1. First clone the repo.
|
|
38
|
-
|
|
39
|
-
```shell
|
|
40
|
-
git clone git@github.com:mindee/mindee-api-ruby.git
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
2. Navigate to the cloned directory and install all required libraries.
|
|
44
|
-
|
|
45
|
-
```shell
|
|
46
|
-
cd mindee-api-ruby
|
|
47
|
-
bundle install
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Updating the Library
|
|
51
|
-
It is important to always check the version of the Mindee OCR SDK you are using, as new and updated
|
|
52
|
-
features wonβt work on older versions.
|
|
53
|
-
|
|
54
|
-
To get the latest version of your OCR SDK:
|
|
55
|
-
|
|
56
|
-
```shell
|
|
57
|
-
gem install mindee
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
To install a specific version of Mindee:
|
|
61
|
-
|
|
62
|
-
```shell
|
|
63
|
-
gem install mindee@<version>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Usage
|
|
67
|
-
|
|
68
|
-
Using Mindee's APIs can be broken down into the following steps:
|
|
69
|
-
|
|
70
|
-
1. [Initialize a Client](#initializing-the-client)
|
|
71
|
-
2. [Load a File](#loading-a-document-file)
|
|
72
|
-
3. [Send the File](#sending-a-file) to Mindee's API
|
|
73
|
-
4. [Process the Result](#process-the-result) in some way
|
|
74
|
-
|
|
75
|
-
Let's take a deep dive into how this works.
|
|
76
|
-
|
|
77
|
-
## Initializing the Client
|
|
78
|
-
The `Client` automatically connects to the default endpoints for each product (or creates one with given parameters for
|
|
79
|
-
Universal APIs).
|
|
80
|
-
|
|
81
|
-
The `Client` requires your [API key](https://developers.mindee.com/docs/make-your-first-request#create-an-api-key).
|
|
82
|
-
|
|
83
|
-
You can either pass these directly to the constructor or through environment variables.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
### Pass the API key directly
|
|
87
|
-
```rb
|
|
88
|
-
# Init a new client and passing the key directly
|
|
89
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Set the API key in the environment
|
|
93
|
-
API keys should be set as environment variables, especially for any production deployment.
|
|
94
|
-
|
|
95
|
-
The following environment variable will set the global API key:
|
|
96
|
-
```shell
|
|
97
|
-
MINDEE_API_KEY=my-api-key
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Then in your code:
|
|
101
|
-
```rb
|
|
102
|
-
# Init a new client without an API key
|
|
103
|
-
mindee_client = Mindee::Client.new
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Setting the Request Timeout
|
|
107
|
-
The request timeout can be set using an environment variable:
|
|
108
|
-
```shell
|
|
109
|
-
MINDEE_REQUEST_TIMEOUT=200
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
## Loading a Document File
|
|
114
|
-
Before being able to send a document to the API, it must first be loaded.
|
|
115
|
-
|
|
116
|
-
You don't need to worry about different MIME types, the library will take care of handling
|
|
117
|
-
all supported types automatically.
|
|
118
|
-
|
|
119
|
-
Once a document is loaded, interacting with it is done in exactly the same way, regardless
|
|
120
|
-
of how it was loaded.
|
|
121
|
-
|
|
122
|
-
There are a few different ways of loading a document file, depending on your use case, you can use a:
|
|
123
|
-
|
|
124
|
-
* [File path](https://developers.mindee.com/docs/ruby-document-loading#loading-from-a-local-path): using the Mindee Client's `source_from_path()` method.
|
|
125
|
-
* [File Object](https://developers.mindee.com/docs/ruby-document-loading#loading-from-a-file-object): using the Mindee Client's `source_from_file()` method.
|
|
126
|
-
* [Base64 String](https://developers.mindee.com/docs/ruby-document-loading#loading-from-a-base64-encoded-string): using the Mindee Client's `source_from_b64string()` method.
|
|
127
|
-
* [Raw Byte sequence](https://developers.mindee.com/docs/ruby-document-loading#loading-from-raw-bytes): using the Mindee Client's `source_from_bytes()` method.
|
|
128
|
-
* [URL](https://developers.mindee.com/docs/ruby-document-loading#loading-by-url): using the Mindee Client's `source_from_url()` method.
|
|
129
|
-
|
|
130
|
-
More details about file loading on the [dedicated page](https://developers.mindee.com/docs/ruby-document-loading).
|
|
131
|
-
|
|
132
|
-
## Sending a File
|
|
133
|
-
To send a file to the API, we need to specify how to process the document.
|
|
134
|
-
This will determine which API endpoint is used and how the API return will be handled internally by the library.
|
|
135
|
-
|
|
136
|
-
More specifically, we need to set a `Mindee::Product` class as the first parameter of the `create_endpoint` method.
|
|
137
|
-
|
|
138
|
-
This is because the `Endpoint`'s urls will be set according to it
|
|
139
|
-
|
|
140
|
-
Each document type available in the library has its corresponding class, which inherit from the base
|
|
141
|
-
`Mindee::Parsing::Common::Predict` class.
|
|
142
|
-
|
|
143
|
-
This is detailed in each document-specific guide.
|
|
144
|
-
|
|
145
|
-
### Off-the-Shelf Documents
|
|
146
|
-
Simply setting the correct class is enough:
|
|
147
|
-
|
|
148
|
-
```rb
|
|
149
|
-
|
|
150
|
-
result = mindee_client.parse(
|
|
151
|
-
input_source,
|
|
152
|
-
Mindee::Product::Invoice::InvoiceV4
|
|
153
|
-
)
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
#### Specific call method
|
|
157
|
-
Some products, such as InvoiceV4, ReceiptV5 & FinancialDocumentV1 support both asynchronous polling and synchronous
|
|
158
|
-
HTTP calls.
|
|
159
|
-
We recommend letting the client library decide which is better by default, but you can override the behavior by setting
|
|
160
|
-
the `enqueue` parameter to `true` or `false`.
|
|
161
|
-
|
|
162
|
-
```rb
|
|
163
|
-
|
|
164
|
-
result = mindee_client.parse(
|
|
165
|
-
input_source,
|
|
166
|
-
Mindee::Product::Invoice::InvoiceV4,
|
|
167
|
-
enqueue: false
|
|
168
|
-
)
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
> π§ WARNING: this feature is not available for all products, and may result in errors if used inappropriately.
|
|
172
|
-
> Only use it if you are certain of what you are doing.
|
|
173
|
-
### Universal Documents (docTI)
|
|
174
|
-
For custom documents, the endpoint to use must also be set, and it must take in an `endpoint_name`:
|
|
175
|
-
|
|
176
|
-
```rb
|
|
177
|
-
endpoint = mindee_client.create_endpoint(endpoint_name: 'wnine', account_name: 'my-account')
|
|
178
|
-
|
|
179
|
-
result = mindee_client.parse(
|
|
180
|
-
input_source,
|
|
181
|
-
Mindee::Product::Universal::Universal,
|
|
182
|
-
endpoint: endpoint
|
|
183
|
-
)
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
This is because the `Universal` class is enough to handle the return processing, but the actual endpoint needs to be
|
|
187
|
-
specified.
|
|
188
|
-
|
|
189
|
-
## Process the Result
|
|
190
|
-
The response object is common to all documents, including custom documents (using the Universal product). The main
|
|
191
|
-
properties are:
|
|
192
|
-
|
|
193
|
-
* `id` β Mindee ID of the document
|
|
194
|
-
* `name` β Filename sent to the API
|
|
195
|
-
* `inference` β [Inference](#inference)
|
|
196
|
-
|
|
197
|
-
### Inference
|
|
198
|
-
Regroups the predictions at the page level, as well as predictions for the entire document.
|
|
199
|
-
|
|
200
|
-
* `prediction` β [Document level prediction](#document-level-prediction)
|
|
201
|
-
* `pages` β [Page level prediction](#page-level-prediction)
|
|
202
|
-
|
|
203
|
-
#### Document level prediction
|
|
204
|
-
The `prediction` attribute is a `Prediction` object specific to the type of document being processed.
|
|
205
|
-
It contains the data extracted from the entire document, all pages combined.
|
|
206
|
-
|
|
207
|
-
It's possible to have the same field in various pages, but at the document level,
|
|
208
|
-
only the highest confidence field data will be shown (this is all done automatically at the API level).
|
|
209
|
-
|
|
210
|
-
```rb
|
|
211
|
-
# as an object, complete
|
|
212
|
-
pp result.document.inference.prediction
|
|
213
|
-
|
|
214
|
-
# as a string, summary in RST format
|
|
215
|
-
puts result.document.inference.prediction
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
#### Page level prediction
|
|
219
|
-
The `pages` attribute is a list of `Prediction` objects.
|
|
220
|
-
|
|
221
|
-
Each page element contains the data extracted for a particular page of the document.
|
|
222
|
-
The order of the elements in the array matches the order of the pages in the document.
|
|
223
|
-
|
|
224
|
-
All response objects have this property, regardless of the number of pages.
|
|
225
|
-
Single page documents will have a single entry.
|
|
226
|
-
|
|
227
|
-
Iteration is done like any Ruby array:
|
|
228
|
-
```rb
|
|
229
|
-
response.document.inference.pages.each do |page|
|
|
230
|
-
# as an object, complete
|
|
231
|
-
pp page.prediction
|
|
232
|
-
|
|
233
|
-
# as a string, summary in RST format
|
|
234
|
-
puts page.prediction
|
|
235
|
-
end
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
#### Page Orientation
|
|
239
|
-
The orientation field is only available at the page level as it describes whether the page image should be rotated to
|
|
240
|
-
be upright.
|
|
241
|
-
|
|
242
|
-
If the page requires rotation for correct display, the orientation field gives a prediction among these 3 possible
|
|
243
|
-
outputs:
|
|
244
|
-
|
|
245
|
-
* 0 degrees: the page is already upright
|
|
246
|
-
* 90 degrees: the page must be rotated clockwise to be upright
|
|
247
|
-
* 270 degrees: the page must be rotated counterclockwise to be upright
|
|
248
|
-
|
|
249
|
-
```rb
|
|
250
|
-
response.document.inference.pages.each do |page|
|
|
251
|
-
puts page.orientation.value
|
|
252
|
-
end
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
## Questions?
|
|
257
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Barcode Reader
|
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
|
4
|
-
slug: ruby-barcode-reader-ocr
|
|
5
|
-
parentDoc: 67b49df15b843f3fa9cd622b
|
|
6
|
-
---
|
|
7
|
-
The Ruby Client Library supports the [Barcode Reader API](https://platform.mindee.com/mindee/barcode_reader).
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> π Product Specs
|
|
11
|
-
>
|
|
12
|
-
> | Specification | Details |
|
|
13
|
-
> | ------------------------------ | -------------------------------------------------- |
|
|
14
|
-
> | Endpoint Name | `barcode_reader` |
|
|
15
|
-
> | Recommended Version | `v1.0` |
|
|
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/barcode_reader/default_sample.jpg),
|
|
22
|
-
we are going to illustrate how to extract the data that we want using the Ruby Client Library.
|
|
23
|
-

|
|
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::BarcodeReader::BarcodeReaderV1
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
# Print a full summary of the parsed data in RST format
|
|
47
|
-
puts result.document
|
|
48
|
-
|
|
49
|
-
# Print the document-level parsed data
|
|
50
|
-
# puts result.document.inference.prediction
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**Output (RST):**
|
|
54
|
-
```rst
|
|
55
|
-
########
|
|
56
|
-
Document
|
|
57
|
-
########
|
|
58
|
-
:Mindee ID: f9c48da1-a306-4805-8da8-f7231fda2d88
|
|
59
|
-
:Filename: default_sample.jpg
|
|
60
|
-
|
|
61
|
-
Inference
|
|
62
|
-
#########
|
|
63
|
-
:Product: mindee/barcode_reader v1.0
|
|
64
|
-
:Rotation applied: Yes
|
|
65
|
-
|
|
66
|
-
Prediction
|
|
67
|
-
==========
|
|
68
|
-
:Barcodes 1D: Mindee
|
|
69
|
-
:Barcodes 2D: https://developers.mindee.com/docs/barcode-reader-ocr
|
|
70
|
-
I love paperwork! - Said no one ever
|
|
71
|
-
|
|
72
|
-
Page Predictions
|
|
73
|
-
================
|
|
74
|
-
|
|
75
|
-
Page 0
|
|
76
|
-
------
|
|
77
|
-
:Barcodes 1D: Mindee
|
|
78
|
-
:Barcodes 2D: https://developers.mindee.com/docs/barcode-reader-ocr
|
|
79
|
-
I love paperwork! - Said no one ever
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
# Field Types
|
|
83
|
-
## Standard Fields
|
|
84
|
-
These fields are generic and used in several products.
|
|
85
|
-
|
|
86
|
-
### Basic Field
|
|
87
|
-
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
|
88
|
-
A typical `Field` object will have the following attributes:
|
|
89
|
-
|
|
90
|
-
* **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
|
|
91
|
-
* **confidence** (Float, nil): the confidence score of the field prediction.
|
|
92
|
-
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
|
93
|
-
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
|
94
|
-
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
|
|
95
|
-
* **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
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.
|
|
99
|
-
|
|
100
|
-
### String Field
|
|
101
|
-
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
|
102
|
-
|
|
103
|
-
# Attributes
|
|
104
|
-
The following fields are extracted for Barcode Reader V1:
|
|
105
|
-
|
|
106
|
-
## Barcodes 1D
|
|
107
|
-
**codes_1d** (Array<[StringField](#string-field)>): List of decoded 1D barcodes.
|
|
108
|
-
|
|
109
|
-
```rb
|
|
110
|
-
result.document.inference.prediction.codes_1d do |codes_1d_elem|
|
|
111
|
-
puts codes_1d_elem.value
|
|
112
|
-
end
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Barcodes 2D
|
|
116
|
-
**codes_2d** (Array<[StringField](#string-field)>): List of decoded 2D barcodes.
|
|
117
|
-
|
|
118
|
-
```rb
|
|
119
|
-
result.document.inference.prediction.codes_2d do |codes_2d_elem|
|
|
120
|
-
puts codes_2d_elem.value
|
|
121
|
-
end
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
# Questions?
|
|
125
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
|
@@ -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
|
-

|
|
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)
|