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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -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/input/sources/local_input_source.rb +9 -1
- 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/product.rb +0 -1
- 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/input/sources/local_input_source.rbs +1 -1
- 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 -47
- data/docs/advanced_file_operations.md +0 -109
- data/docs/code_samples/us_mail_v2_async.txt +0 -24
- 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/lib/mindee/product/us/us_mail/us_mail_v2.rb +0 -47
- data/lib/mindee/product/us/us_mail/us_mail_v2_document.rb +0 -105
- data/lib/mindee/product/us/us_mail/us_mail_v2_page.rb +0 -38
- data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +0 -105
- data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb +0 -63
- data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +0 -66
- data/sig/mindee/product/us/us_mail/us_mail_v2.rbs +0 -13
- data/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs +0 -20
- data/sig/mindee/product/us/us_mail/us_mail_v2_page.rbs +0 -17
- data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs +0 -22
- data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs +0 -15
- data/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs +0 -18
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: FR Energy Bill
|
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
|
4
|
-
slug: ruby-fr-energy-bill-ocr
|
|
5
|
-
parentDoc: 67b49e29a2cd6f08d69a40d8
|
|
6
|
-
---
|
|
7
|
-
The Ruby Client Library supports the [Energy Bill API](https://platform.mindee.com/mindee/energy_bill_fra).
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> 📝 Product Specs
|
|
11
|
-
>
|
|
12
|
-
> | Specification | Details |
|
|
13
|
-
> | ------------------------------ | -------------------------------------------------- |
|
|
14
|
-
> | Endpoint Name | `energy_bill_fra` |
|
|
15
|
-
> | Recommended Version | `v1.2` |
|
|
16
|
-
> | Supports Polling/Webhooks | ✔️ Yes |
|
|
17
|
-
> | Support Synchronous HTTP Calls | ❌ No |
|
|
18
|
-
> | Geography | 🇫🇷 France |
|
|
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/energy_bill_fra/default_sample.pdf),
|
|
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::FR::EnergyBill::EnergyBillV1
|
|
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: ff1f2ca8-4d29-44d8-a564-599a982a4ef7
|
|
67
|
-
:Filename: default_sample.pdf
|
|
68
|
-
|
|
69
|
-
Inference
|
|
70
|
-
#########
|
|
71
|
-
:Product: mindee/energy_bill_fra v1.2
|
|
72
|
-
:Rotation applied: Yes
|
|
73
|
-
|
|
74
|
-
Prediction
|
|
75
|
-
==========
|
|
76
|
-
:Invoice Number: 1234567890
|
|
77
|
-
:Contract ID: 9876543210
|
|
78
|
-
:Delivery Point: 98765432109876
|
|
79
|
-
:Invoice Date: 2021-01-29
|
|
80
|
-
:Due Date: 2021-02-15
|
|
81
|
-
:Total Before Taxes: 1241.03
|
|
82
|
-
:Total Taxes: 238.82
|
|
83
|
-
:Total Amount: 1479.85
|
|
84
|
-
:Energy Supplier:
|
|
85
|
-
:Address: TSA 12345, 12345 DEMOCITY CEDEX
|
|
86
|
-
:Name: EDF
|
|
87
|
-
:Energy Consumer:
|
|
88
|
-
:Address: 123 RUE DE L'IMAGINAIRE, 75001 PARIS
|
|
89
|
-
:Name: JOHN DOE
|
|
90
|
-
:Subscription:
|
|
91
|
-
+--------------------------------------+------------+------------+----------+-----------+------------+
|
|
92
|
-
| Description | End Date | Start Date | Tax Rate | Total | Unit Price |
|
|
93
|
-
+======================================+============+============+==========+===========+============+
|
|
94
|
-
| Abonnement électricité | 2021-02-28 | 2021-01-01 | 5.50 | 59.00 | 29.50 |
|
|
95
|
-
+--------------------------------------+------------+------------+----------+-----------+------------+
|
|
96
|
-
:Energy Usage:
|
|
97
|
-
+-------------+--------------------------------------+------------+------------+----------+-----------+-----------------+------------+
|
|
98
|
-
| Consumption | Description | End Date | Start Date | Tax Rate | Total | Unit of Measure | Unit Price |
|
|
99
|
-
+=============+======================================+============+============+==========+===========+=================+============+
|
|
100
|
-
| 8581.00 | Consommation électricité | 2021-01-27 | 2020-11-28 | 20.00 | 898.43 | kWh | 0.1047 |
|
|
101
|
-
+-------------+--------------------------------------+------------+------------+----------+-----------+-----------------+------------+
|
|
102
|
-
:Taxes and Contributions:
|
|
103
|
-
+--------------------------------------+------------+------------+----------+-----------+------------+
|
|
104
|
-
| Description | End Date | Start Date | Tax Rate | Total | Unit Price |
|
|
105
|
-
+======================================+============+============+==========+===========+============+
|
|
106
|
-
| Contribution au Service Public de... | 2021-01-27 | 2020-11-28 | 20.00 | 193.07 | 0.0225 |
|
|
107
|
-
+--------------------------------------+------------+------------+----------+-----------+------------+
|
|
108
|
-
| Taxe Départementale sur la Conso ... | 2021-01-27 | 2020-11-28 | 20.00 | 13.98 | 0.003315 |
|
|
109
|
-
+--------------------------------------+------------+------------+----------+-----------+------------+
|
|
110
|
-
| Taxe Communale sur la Conso Final... | 2021-01-27 | 2020-11-28 | 20.00 | 28.56 | 0.006545 |
|
|
111
|
-
+--------------------------------------+------------+------------+----------+-----------+------------+
|
|
112
|
-
| Taxe Communale sur la Conso Final... | 2021-01-27 | 2020-11-28 | 20.00 | 27.96 | 0.00663 |
|
|
113
|
-
+--------------------------------------+------------+------------+----------+-----------+------------+
|
|
114
|
-
:Meter Details:
|
|
115
|
-
:Meter Number: 620
|
|
116
|
-
:Meter Type: electricity
|
|
117
|
-
:Unit of Power: 36kVA
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
# Field Types
|
|
121
|
-
## Standard Fields
|
|
122
|
-
These fields are generic and used in several products.
|
|
123
|
-
|
|
124
|
-
### Basic Field
|
|
125
|
-
Each prediction object contains a set of fields that inherit from the generic `Field` class.
|
|
126
|
-
A typical `Field` object will have the following attributes:
|
|
127
|
-
|
|
128
|
-
* **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
|
|
129
|
-
* **confidence** (Float, nil): the confidence score of the field prediction.
|
|
130
|
-
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
|
|
131
|
-
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
|
|
132
|
-
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
|
|
133
|
-
* **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
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.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
### Amount Field
|
|
140
|
-
The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
|
|
141
|
-
|
|
142
|
-
### Date Field
|
|
143
|
-
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
|
|
144
|
-
|
|
145
|
-
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
|
|
146
|
-
|
|
147
|
-
### String Field
|
|
148
|
-
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
|
|
149
|
-
|
|
150
|
-
## Specific Fields
|
|
151
|
-
Fields which are specific to this product; they are not used in any other product.
|
|
152
|
-
|
|
153
|
-
### Energy Supplier Field
|
|
154
|
-
The company that supplies the energy.
|
|
155
|
-
|
|
156
|
-
A `EnergyBillV1EnergySupplier` implements the following attributes:
|
|
157
|
-
|
|
158
|
-
* `address` (String): The address of the energy supplier.
|
|
159
|
-
* `name` (String): The name of the energy supplier.
|
|
160
|
-
Fields which are specific to this product; they are not used in any other product.
|
|
161
|
-
|
|
162
|
-
### Energy Consumer Field
|
|
163
|
-
The entity that consumes the energy.
|
|
164
|
-
|
|
165
|
-
A `EnergyBillV1EnergyConsumer` implements the following attributes:
|
|
166
|
-
|
|
167
|
-
* `address` (String): The address of the energy consumer.
|
|
168
|
-
* `name` (String): The name of the energy consumer.
|
|
169
|
-
Fields which are specific to this product; they are not used in any other product.
|
|
170
|
-
|
|
171
|
-
### Subscription Field
|
|
172
|
-
The subscription details fee for the energy service.
|
|
173
|
-
|
|
174
|
-
A `EnergyBillV1Subscription` implements the following attributes:
|
|
175
|
-
|
|
176
|
-
* `description` (String): Description or details of the subscription.
|
|
177
|
-
* `end_date` (String): The end date of the subscription.
|
|
178
|
-
* `start_date` (String): The start date of the subscription.
|
|
179
|
-
* `tax_rate` (Float): The rate of tax applied to the total cost.
|
|
180
|
-
* `total` (Float): The total cost of subscription.
|
|
181
|
-
* `unit_price` (Float): The price per unit of subscription.
|
|
182
|
-
Fields which are specific to this product; they are not used in any other product.
|
|
183
|
-
|
|
184
|
-
### Energy Usage Field
|
|
185
|
-
Details of energy consumption.
|
|
186
|
-
|
|
187
|
-
A `EnergyBillV1EnergyUsage` implements the following attributes:
|
|
188
|
-
|
|
189
|
-
* `consumption` (Float): The price per unit of energy consumed.
|
|
190
|
-
* `description` (String): Description or details of the energy usage.
|
|
191
|
-
* `end_date` (String): The end date of the energy usage.
|
|
192
|
-
* `start_date` (String): The start date of the energy usage.
|
|
193
|
-
* `tax_rate` (Float): The rate of tax applied to the total cost.
|
|
194
|
-
* `total` (Float): The total cost of energy consumed.
|
|
195
|
-
* `unit` (String): The unit of measurement for energy consumption.
|
|
196
|
-
|
|
197
|
-
#### Possible values include:
|
|
198
|
-
- kWh
|
|
199
|
-
- m3
|
|
200
|
-
- L
|
|
201
|
-
|
|
202
|
-
* `unit_price` (Float): The price per unit of energy consumed.
|
|
203
|
-
Fields which are specific to this product; they are not used in any other product.
|
|
204
|
-
|
|
205
|
-
### Taxes and Contributions Field
|
|
206
|
-
Details of Taxes and Contributions.
|
|
207
|
-
|
|
208
|
-
A `EnergyBillV1TaxesAndContribution` implements the following attributes:
|
|
209
|
-
|
|
210
|
-
* `description` (String): Description or details of the Taxes and Contributions.
|
|
211
|
-
* `end_date` (String): The end date of the Taxes and Contributions.
|
|
212
|
-
* `start_date` (String): The start date of the Taxes and Contributions.
|
|
213
|
-
* `tax_rate` (Float): The rate of tax applied to the total cost.
|
|
214
|
-
* `total` (Float): The total cost of Taxes and Contributions.
|
|
215
|
-
* `unit_price` (Float): The price per unit of Taxes and Contributions.
|
|
216
|
-
Fields which are specific to this product; they are not used in any other product.
|
|
217
|
-
|
|
218
|
-
### Meter Details Field
|
|
219
|
-
Information about the energy meter.
|
|
220
|
-
|
|
221
|
-
A `EnergyBillV1MeterDetail` implements the following attributes:
|
|
222
|
-
|
|
223
|
-
* `meter_number` (String): The unique identifier of the energy meter.
|
|
224
|
-
* `meter_type` (String): The type of energy meter.
|
|
225
|
-
|
|
226
|
-
#### Possible values include:
|
|
227
|
-
- electricity
|
|
228
|
-
- gas
|
|
229
|
-
- water
|
|
230
|
-
- None
|
|
231
|
-
|
|
232
|
-
* `unit` (String): The unit of power for energy consumption.
|
|
233
|
-
|
|
234
|
-
# Attributes
|
|
235
|
-
The following fields are extracted for Energy Bill V1:
|
|
236
|
-
|
|
237
|
-
## Contract ID
|
|
238
|
-
**contract_id** ([StringField](#string-field)): The unique identifier associated with a specific contract.
|
|
239
|
-
|
|
240
|
-
```rb
|
|
241
|
-
puts result.document.inference.prediction.contract_id.value
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
## Delivery Point
|
|
245
|
-
**delivery_point** ([StringField](#string-field)): The unique identifier assigned to each electricity or gas consumption point. It specifies the exact location where the energy is delivered.
|
|
246
|
-
|
|
247
|
-
```rb
|
|
248
|
-
puts result.document.inference.prediction.delivery_point.value
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
## Due Date
|
|
252
|
-
**due_date** ([DateField](#date-field)): The date by which the payment for the energy invoice is due.
|
|
253
|
-
|
|
254
|
-
```rb
|
|
255
|
-
puts result.document.inference.prediction.due_date.value
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
## Energy Consumer
|
|
259
|
-
**energy_consumer** ([EnergyBillV1EnergyConsumer](#energy-consumer-field)): The entity that consumes the energy.
|
|
260
|
-
|
|
261
|
-
```rb
|
|
262
|
-
puts result.document.inference.prediction.energy_consumer.value
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
## Energy Supplier
|
|
266
|
-
**energy_supplier** ([EnergyBillV1EnergySupplier](#energy-supplier-field)): The company that supplies the energy.
|
|
267
|
-
|
|
268
|
-
```rb
|
|
269
|
-
puts result.document.inference.prediction.energy_supplier.value
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
## Energy Usage
|
|
273
|
-
**energy_usage** (Array<[EnergyBillV1EnergyUsage](#energy-usage-field)>): Details of energy consumption.
|
|
274
|
-
|
|
275
|
-
```rb
|
|
276
|
-
result.document.inference.prediction.energy_usage do |energy_usage_elem|
|
|
277
|
-
puts energy_usage_elem.value
|
|
278
|
-
end
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
## Invoice Date
|
|
282
|
-
**invoice_date** ([DateField](#date-field)): The date when the energy invoice was issued.
|
|
283
|
-
|
|
284
|
-
```rb
|
|
285
|
-
puts result.document.inference.prediction.invoice_date.value
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
## Invoice Number
|
|
289
|
-
**invoice_number** ([StringField](#string-field)): The unique identifier of the energy invoice.
|
|
290
|
-
|
|
291
|
-
```rb
|
|
292
|
-
puts result.document.inference.prediction.invoice_number.value
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
## Meter Details
|
|
296
|
-
**meter_details** ([EnergyBillV1MeterDetail](#meter-details-field)): Information about the energy meter.
|
|
297
|
-
|
|
298
|
-
```rb
|
|
299
|
-
puts result.document.inference.prediction.meter_details.value
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
## Subscription
|
|
303
|
-
**subscription** (Array<[EnergyBillV1Subscription](#subscription-field)>): The subscription details fee for the energy service.
|
|
304
|
-
|
|
305
|
-
```rb
|
|
306
|
-
result.document.inference.prediction.subscription do |subscription_elem|
|
|
307
|
-
puts subscription_elem.value
|
|
308
|
-
end
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
## Taxes and Contributions
|
|
312
|
-
**taxes_and_contributions** (Array<[EnergyBillV1TaxesAndContribution](#taxes-and-contributions-field)>): Details of Taxes and Contributions.
|
|
313
|
-
|
|
314
|
-
```rb
|
|
315
|
-
result.document.inference.prediction.taxes_and_contributions do |taxes_and_contributions_elem|
|
|
316
|
-
puts taxes_and_contributions_elem.value
|
|
317
|
-
end
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
## Total Amount
|
|
321
|
-
**total_amount** ([AmountField](#amount-field)): The total amount to be paid for the energy invoice.
|
|
322
|
-
|
|
323
|
-
```rb
|
|
324
|
-
puts result.document.inference.prediction.total_amount.value
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
## Total Before Taxes
|
|
328
|
-
**total_before_taxes** ([AmountField](#amount-field)): The total amount to be paid for the energy invoice before taxes.
|
|
329
|
-
|
|
330
|
-
```rb
|
|
331
|
-
puts result.document.inference.prediction.total_before_taxes.value
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
## Total Taxes
|
|
335
|
-
**total_taxes** ([AmountField](#amount-field)): Total of taxes applied to the invoice.
|
|
336
|
-
|
|
337
|
-
```rb
|
|
338
|
-
puts result.document.inference.prediction.total_taxes.value
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
# Questions?
|
|
342
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: FR Health Card
|
|
3
|
-
category: 622b805aaec68102ea7fcbc2
|
|
4
|
-
slug: ruby-fr-health-card-ocr
|
|
5
|
-
parentDoc: 67b49e29a2cd6f08d69a40d8
|
|
6
|
-
---
|
|
7
|
-
The Ruby Client Library supports the [Health Card API](https://platform.mindee.com/mindee/french_healthcard).
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> 📝 Product Specs
|
|
11
|
-
>
|
|
12
|
-
> | Specification | Details |
|
|
13
|
-
> | ------------------------------ | -------------------------------------------------- |
|
|
14
|
-
> | Endpoint Name | `french_healthcard` |
|
|
15
|
-
> | Recommended Version | `v1.0` |
|
|
16
|
-
> | Supports Polling/Webhooks | ✔️ Yes |
|
|
17
|
-
> | Support Synchronous HTTP Calls | ❌ No |
|
|
18
|
-
> | Geography | 🇫🇷 France |
|
|
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/french_healthcard/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::FR::HealthCard::HealthCardV1
|
|
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: 9ee2733d-933a-4dcd-a73a-a31395e3b288
|
|
67
|
-
:Filename: default_sample.jpg
|
|
68
|
-
|
|
69
|
-
Inference
|
|
70
|
-
#########
|
|
71
|
-
:Product: mindee/french_healthcard v1.0
|
|
72
|
-
:Rotation applied: Yes
|
|
73
|
-
|
|
74
|
-
Prediction
|
|
75
|
-
==========
|
|
76
|
-
:Given Name(s): NATHALIE
|
|
77
|
-
:Surname: DURAND
|
|
78
|
-
:Social Security Number: 2 69 05 49 588 157 80
|
|
79
|
-
:Issuance Date: 2007-01-01
|
|
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
|
-
### 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 Health Card V1:
|
|
110
|
-
|
|
111
|
-
## Given Name(s)
|
|
112
|
-
**given_names** (Array<[StringField](#string-field)>): The given names of the card holder.
|
|
113
|
-
|
|
114
|
-
```rb
|
|
115
|
-
result.document.inference.prediction.given_names do |given_names_elem|
|
|
116
|
-
puts given_names_elem.value
|
|
117
|
-
end
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Issuance Date
|
|
121
|
-
**issuance_date** ([DateField](#date-field)): The date when the carte vitale document was issued.
|
|
122
|
-
|
|
123
|
-
```rb
|
|
124
|
-
puts result.document.inference.prediction.issuance_date.value
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Social Security Number
|
|
128
|
-
**social_security** ([StringField](#string-field)): The social security number of the card holder.
|
|
129
|
-
|
|
130
|
-
```rb
|
|
131
|
-
puts result.document.inference.prediction.social_security.value
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Surname
|
|
135
|
-
**surname** ([StringField](#string-field)): The surname of the card holder.
|
|
136
|
-
|
|
137
|
-
```rb
|
|
138
|
-
puts result.document.inference.prediction.surname.value
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
# Questions?
|
|
142
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|