mindee 2.0.0 → 2.1.1
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/.gitignore +1 -0
- data/.yardopts +0 -1
- data/CHANGELOG.md +15 -0
- data/README.md +13 -9
- data/Rakefile +9 -1
- data/bin/mindee.rb +8 -0
- data/docs/code_samples/bank_account_details_v1.txt +14 -0
- data/docs/code_samples/bank_check_v1.txt +14 -0
- data/docs/code_samples/carte_vitale_v1.txt +14 -0
- data/docs/code_samples/custom_v1.txt +24 -0
- data/docs/code_samples/default.txt +16 -0
- data/docs/code_samples/expense_receipts_v4.txt +14 -0
- data/docs/code_samples/financial_document_v1.txt +14 -0
- data/docs/code_samples/idcard_fr_v1.txt +14 -0
- data/docs/code_samples/invoices_v4.txt +14 -0
- data/docs/code_samples/license_plates_v1.txt +14 -0
- data/docs/code_samples/passport_v1.txt +14 -0
- data/docs/code_samples/proof_of_address_v1.txt +14 -0
- data/docs/code_samples/shipping_containers_v1.txt +14 -0
- data/docs/ruby-api-builder.md +35 -42
- data/docs/ruby-getting-started.md +2 -2
- data/docs/ruby-invoice-ocr.md +12 -13
- data/docs/ruby-passport-ocr.md +1 -1
- data/docs/ruby-receipt-ocr.md +1 -1
- data/lib/mindee/client.rb +34 -30
- data/lib/mindee/document_config.rb +15 -23
- data/lib/mindee/parsing/prediction/financial_document/financial_document_v1.rb +245 -0
- data/lib/mindee/parsing/prediction/financial_document/invoice_line_item.rb +58 -0
- data/lib/mindee/parsing/prediction/passport/passport_v1.rb +0 -63
- data/lib/mindee/parsing/prediction/proof_of_address/proof_of_address_v1.rb +80 -0
- data/lib/mindee/parsing/prediction/receipt/receipt_v4.rb +3 -0
- data/lib/mindee/parsing/prediction.rb +2 -0
- data/lib/mindee/version.rb +1 -1
- data/mindee.gemspec +2 -3
- metadata +24 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 927e4d22c8f54feebaace71c40705a1e130d4737fce8487ae24b7c369f2aa3ea
|
4
|
+
data.tar.gz: 99101cdf1573be19a82ee0cd04bd54cc45edff95bac113902174f45c3ae4de4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38b335f5baf0b8a4757e31956472314f11e01d901c24e8e24990f48e90292d0bac7c4aba79a30ea4db27188c88d7957282fc19d08c653b3b7fce489a923f6c9a
|
7
|
+
data.tar.gz: 8f87a88fff6e4284a326c563f60e67c8a85e2516cb96f103ba648b5ac2366298e59fc1c60f120f4e797b738c71dc391dc881317bd1e9825d2a3f9513f9b63e5d
|
data/.gitignore
CHANGED
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Mindee Ruby API Library Changelog
|
2
2
|
|
3
|
+
## v2.1.1 - 2023-04-21
|
4
|
+
### Changes
|
5
|
+
* :memo: minor docstring improvements
|
6
|
+
* :coffin: remove redundant local checks
|
7
|
+
* :memo: publish documentation
|
8
|
+
* :memo: add code samples
|
9
|
+
|
10
|
+
|
11
|
+
## v2.1.0 - 2023-01-30
|
12
|
+
### Changes
|
13
|
+
* :sparkles: Add financial document v1 support (Co-authored-by: Oriol Gual)
|
14
|
+
* :sparkles: Add Proof of Address v1 support
|
15
|
+
|
16
|
+
|
3
17
|
## v2.0.0 - 2023-01-13
|
4
18
|
### ¡Breaking Changes!
|
5
19
|
* :sparkles: add improved PDF merge system
|
@@ -17,6 +31,7 @@
|
|
17
31
|
* :white_check_mark: add testing on Ruby 3.2
|
18
32
|
* :sparkles: allow setting the request timeout from env
|
19
33
|
|
34
|
+
|
20
35
|
## v1.2.0 - 2022-12-26
|
21
36
|
### Changes
|
22
37
|
* :arrow_up: switch to origamindee => adds support for Ruby 3
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
|
52
52
|
.parse(Mindee::Prediction::EU::LicensePlateV1)
|
53
53
|
|
54
54
|
# Print a full summary of the parsed data in RST format
|
55
|
-
puts result
|
55
|
+
puts result
|
56
56
|
```
|
57
57
|
|
58
58
|
### Custom Document (API Builder)
|
@@ -61,13 +61,13 @@ require 'mindee'
|
|
61
61
|
|
62
62
|
# Init a new client and configure your custom document
|
63
63
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key').add_endpoint(
|
64
|
-
'
|
65
|
-
'
|
64
|
+
'my-account',
|
65
|
+
'my-endpoint'
|
66
66
|
)
|
67
67
|
|
68
68
|
# Load a file from disk and parse it
|
69
69
|
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
70
|
-
.parse(Mindee::Prediction::CustomV1, endpoint_name: '
|
70
|
+
.parse(Mindee::Prediction::CustomV1, endpoint_name: 'my-endpoint')
|
71
71
|
|
72
72
|
# Print a full summary of the parsed data in RST format
|
73
73
|
puts result
|
@@ -84,11 +84,15 @@ end
|
|
84
84
|
There's more to it than that for those that need more features, or want to
|
85
85
|
customize the experience.
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
* [Ruby Overview](https://developers.mindee.com/docs/ruby-getting-started)
|
88
|
+
* [Ruby Custom APIs OCR](https://developers.mindee.com/docs/ruby-api-builder)
|
89
|
+
* [Ruby invoices OCR](https://developers.mindee.com/docs/ruby-invoice-ocr)
|
90
|
+
* [Ruby receipts OCR](https://developers.mindee.com/docs/ruby-receipt-ocr)
|
91
|
+
* [Ruby passports OCR](https://developers.mindee.com/docs/ruby-passport-ocr)
|
92
|
+
|
93
|
+
You can also take a look at the
|
94
|
+
[Reference Documentation](https://mindee.github.io/mindee-api-ruby/).
|
95
|
+
|
92
96
|
|
93
97
|
## License
|
94
98
|
Copyright © Mindee, SA
|
data/Rakefile
CHANGED
@@ -15,6 +15,14 @@ task default: :spec
|
|
15
15
|
|
16
16
|
RSpec::Core::RakeTask.new(:spec)
|
17
17
|
|
18
|
-
|
18
|
+
desc 'Generate documentation'
|
19
|
+
YARD::Rake::YardocTask.new(:doc) do |task|
|
19
20
|
task.files = ['lib/**/*.rb']
|
20
21
|
end
|
22
|
+
|
23
|
+
Rake::Task[:doc].enhance do
|
24
|
+
FileUtils.cp_r(
|
25
|
+
File.join('docs', 'code_samples'),
|
26
|
+
File.join('docs', '_build')
|
27
|
+
)
|
28
|
+
end
|
data/bin/mindee.rb
CHANGED
@@ -10,6 +10,14 @@ DOCUMENTS = {
|
|
10
10
|
help: "Custom document type from API builder",
|
11
11
|
prediction: Mindee::Prediction::CustomV1,
|
12
12
|
},
|
13
|
+
"proof-of-address" => {
|
14
|
+
help: 'Proof of Address',
|
15
|
+
prediction: Mindee::Prediction::ProofOfAddressV1,
|
16
|
+
},
|
17
|
+
"financial-document" => {
|
18
|
+
help: 'Financial Document',
|
19
|
+
prediction: Mindee::Prediction::FinancialDocumentV1,
|
20
|
+
},
|
13
21
|
"invoice" => {
|
14
22
|
help: 'Invoice',
|
15
23
|
prediction: Mindee::Prediction::InvoiceV4,
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::FR::BankAccountDetailsV1)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::US::BankCheckV1)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::FR::CarteVitaleV1)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client and configure your custom document
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key').add_endpoint(
|
5
|
+
'my-account',
|
6
|
+
'my-endpoint'
|
7
|
+
)
|
8
|
+
|
9
|
+
# Load a file from disk and parse it
|
10
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
11
|
+
.parse(Mindee::Prediction::CustomV1, endpoint_name: 'my-endpoint')
|
12
|
+
|
13
|
+
# Print a full summary of the parsed data in RST format
|
14
|
+
puts result
|
15
|
+
|
16
|
+
# Print the document-level parsed data
|
17
|
+
# puts result.inference.prediction
|
18
|
+
|
19
|
+
# Looping over all prediction values
|
20
|
+
result.inference.prediction.fields.each do |field_name, field_data|
|
21
|
+
puts field_name
|
22
|
+
puts field_data.values
|
23
|
+
puts field_data.to_s
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
|
5
|
+
url = URI('https://api.mindee.net/v1/products/mindee/my-endpoint/my-version/predict')
|
6
|
+
file = '/path/to/the/file.ext'
|
7
|
+
|
8
|
+
http = Net::HTTP.new(url.host, url.port)
|
9
|
+
http.use_ssl = true
|
10
|
+
|
11
|
+
request = Net::HTTP::Post.new(url)
|
12
|
+
request['Authorization'] = 'Token my-api-key'
|
13
|
+
request.set_form([['document', File.open(file)]], 'multipart/form-data')
|
14
|
+
|
15
|
+
response = http.request(request)
|
16
|
+
puts response.read_body
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::ReceiptV4)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::FinancialDocumentV1)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::FR::IdCardV1)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::InvoiceV4)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::EU::LicensePlateV1)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::PassportV1)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::ProofOfAddressV1)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk and parse it
|
7
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
8
|
+
.parse(Mindee::Prediction::ShippingContainerV1)
|
9
|
+
|
10
|
+
# Print a full summary of the parsed data in RST format
|
11
|
+
puts result
|
12
|
+
|
13
|
+
# Print the document-level parsed data
|
14
|
+
# puts result.inference.prediction
|
data/docs/ruby-api-builder.md
CHANGED
@@ -1,34 +1,32 @@
|
|
1
|
-
The Ruby OCR SDK supports [custom-built API](https://developers.mindee.com/docs/build-your-first-document-parsing-api)
|
2
|
-
from the API Builder.
|
1
|
+
The Ruby OCR SDK supports [custom-built API](https://developers.mindee.com/docs/build-your-first-document-parsing-api) from the API Builder.
|
3
2
|
|
4
3
|
If your document isn't covered by one of Mindee's Off-the-Shelf APIs, you can create your own API using the
|
5
4
|
[API Builder](https://developers.mindee.com/docs/overview).
|
6
5
|
|
7
|
-
For the following examples, we are using our own [W9s custom API](https://developers.mindee.com/docs/w9-forms-ocr)
|
6
|
+
For the following examples, we are using our own [W9s custom API](https://developers.mindee.com/docs/w9-forms-ocr),
|
8
7
|
created with the [API Builder](https://developers.mindee.com/docs/overview).
|
9
8
|
|
10
9
|
> 📘 **Info**
|
11
10
|
>
|
12
|
-
> We used a data model that
|
13
|
-
> change the `
|
11
|
+
> We used a data model that will be different from yours.
|
12
|
+
> To modify this to your own custom API, change the `add_endpoint` call with your own parameters.
|
14
13
|
|
15
14
|
```ruby
|
16
15
|
require 'mindee'
|
17
16
|
|
18
17
|
# Init a new client and configure your custom document
|
19
|
-
mindee_client = Mindee::Client.new(
|
20
|
-
api_key: 'my-api-key', # optional, can be set in environment
|
21
|
-
).config_custom_doc(
|
22
|
-
'wsnine',
|
18
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key').add_endpoint(
|
23
19
|
'john',
|
20
|
+
'wnine',
|
24
21
|
version: '1.1' # optional, if not set, use the latest version of the model
|
25
22
|
)
|
26
23
|
|
27
24
|
# Load a file from disk and parse it
|
28
|
-
|
25
|
+
result = mindee_client.doc_from_path('/path/to/file.ext')
|
26
|
+
.parse(Mindee::Prediction::CustomV1, endpoint_name: 'wnine')
|
29
27
|
|
30
|
-
# Print a
|
31
|
-
puts
|
28
|
+
# Print a summary of the document prediction in RST format
|
29
|
+
puts result
|
32
30
|
```
|
33
31
|
|
34
32
|
If the `version` argument is set, you'll be required to update it every time a new model is trained.
|
@@ -39,7 +37,8 @@ The client calls the `parse` method when parsing your custom document, which wil
|
|
39
37
|
The document type must be specified when calling the parse method.
|
40
38
|
|
41
39
|
```ruby
|
42
|
-
result = mindee_client.doc_from_path('/path/to/custom_file')
|
40
|
+
result = mindee_client.doc_from_path('/path/to/custom_file')
|
41
|
+
.parse(Mindee::Prediction::CustomV1, endpoint_name: 'wnine')
|
43
42
|
puts result
|
44
43
|
```
|
45
44
|
|
@@ -49,13 +48,13 @@ puts result
|
|
49
48
|
> you **must** specify your account name when calling the `parse` method:
|
50
49
|
|
51
50
|
```ruby
|
52
|
-
mindee_client = Mindee::Client.new.
|
51
|
+
mindee_client = Mindee::Client.new.add_endpoint(
|
53
52
|
'receipt',
|
54
53
|
'john'
|
55
54
|
)
|
56
55
|
|
57
56
|
result = mindee_client.doc_from_path('/path/to/receipt.jpg')
|
58
|
-
.parse(
|
57
|
+
.parse(Mindee::Prediction::CustomV1, account_name: 'john')
|
59
58
|
```
|
60
59
|
|
61
60
|
## Document Fields
|
@@ -64,64 +63,58 @@ All the fields defined in the API builder when creating your custom document are
|
|
64
63
|
In custom documents, each field will hold an array of all the words in the document which are related to that field.
|
65
64
|
Each word is an object that has the text content, geometry information, and confidence score.
|
66
65
|
|
67
|
-
Value fields can be accessed
|
66
|
+
Value fields can be accessed via the `fields` attribute.
|
68
67
|
|
69
|
-
Classification fields can be accessed
|
68
|
+
Classification fields can be accessed via the `classifications` attribute.
|
70
69
|
|
71
70
|
> 📘 **Info**
|
72
71
|
>
|
73
72
|
> Both document level and page level objects work in the same way.
|
74
73
|
|
75
|
-
###
|
76
|
-
|
74
|
+
### Fields Attribute
|
75
|
+
The `fields` attribute is a hashmap with the following structure:
|
76
|
+
|
77
|
+
* key: the API name of the field, as a `symbol`
|
78
|
+
* value: a `ListField` object which has a `values` attribute, containing a list of all values found for the field.
|
79
|
+
|
80
|
+
Individual field values can be accessed by using the field's API name, in the examples below we'll use the `address` field.
|
77
81
|
|
78
82
|
```ruby
|
79
83
|
# raw data, list of each word object
|
80
|
-
|
84
|
+
pp result.inference.prediction.fields[:address].values
|
81
85
|
|
82
86
|
# list of all values
|
83
|
-
puts
|
87
|
+
puts result.inference.prediction.fields[:address].contents_list
|
84
88
|
|
85
89
|
# default string representation
|
86
|
-
puts
|
90
|
+
puts result.inference.prediction.fields[:address].to_s
|
87
91
|
|
88
92
|
# custom string representation
|
89
|
-
puts
|
93
|
+
puts result.inference.prediction.fields[:address].contents_str(separator: '_')
|
90
94
|
```
|
91
95
|
|
92
|
-
|
93
|
-
In addition to accessing a value field directly, it's possible to access it through the `fields` attribute.
|
94
|
-
It's a hashmap with the following structure:
|
95
|
-
* key: the API name of the field, as a `symbol`
|
96
|
-
* value: a `ListField` object which has a `values` attribute, containing a list of all values found for the field.
|
97
|
-
|
98
|
-
```ruby
|
99
|
-
# raw data, list of each word object
|
100
|
-
puts w9_data.document.fields[:address].values
|
101
|
-
```
|
102
|
-
|
103
|
-
This makes it simple to iterate over all the fields:
|
96
|
+
To iterate over all the fields:
|
104
97
|
```ruby
|
105
|
-
|
98
|
+
result.inference.prediction.fields.each do |name, info|
|
106
99
|
puts name
|
107
100
|
puts info.values
|
108
101
|
end
|
109
102
|
```
|
110
103
|
|
111
|
-
### Classifications
|
112
|
-
|
113
|
-
|
104
|
+
### Classifications Attribute
|
105
|
+
The `classifications` attribute is a hashmap with the following structure:
|
106
|
+
|
114
107
|
* key: the API name of the field, as a `symbol`
|
115
108
|
* value: a `ClassificationField` object which has a `value` attribute, containing a string representation of the detected classification.
|
116
109
|
|
117
110
|
```ruby
|
118
111
|
# raw data, list of each word object
|
119
|
-
puts
|
112
|
+
puts result.document.classifications[:doc_type].value
|
120
113
|
```
|
121
114
|
|
122
|
-
|
115
|
+
To iterate over all the classifications:
|
123
116
|
```ruby
|
124
|
-
|
117
|
+
result.document.classifications.each do |name, info|
|
125
118
|
puts name
|
126
119
|
puts info.value
|
127
120
|
end
|
@@ -45,7 +45,7 @@ cd mindee-api-ruby
|
|
45
45
|
bundle install
|
46
46
|
```
|
47
47
|
|
48
|
-
|
48
|
+
### Updating the Library
|
49
49
|
It is important to always check the version of the Mindee OCR SDK you are using, as new and updated
|
50
50
|
features won’t work on older versions.
|
51
51
|
|
@@ -64,7 +64,7 @@ gem install mindee@<version>
|
|
64
64
|
## Usage
|
65
65
|
Using Mindee's APIs can be broken down into the following steps:
|
66
66
|
|
67
|
-
1. [Initialize a
|
67
|
+
1. [Initialize a Client](#initializing-the-client)
|
68
68
|
2. [Load a File](#loading-a-document-file)
|
69
69
|
3. [Send the File](#sending-a-file) to Mindee's API
|
70
70
|
4. [Process the Result](#process-the-result) in some way
|
data/docs/ruby-invoice-ocr.md
CHANGED
@@ -19,7 +19,7 @@ puts result.inference.prediction
|
|
19
19
|
```
|
20
20
|
|
21
21
|
Output:
|
22
|
-
```
|
22
|
+
```
|
23
23
|
:Locale: en; en; CAD;
|
24
24
|
:Document type: INVOICE
|
25
25
|
:Invoice number: 14
|
@@ -48,8 +48,10 @@ Code QTY Price Amount Tax (Rate) Descript
|
|
48
48
|
====================== ======== ========= ========== ================== ====================================
|
49
49
|
```
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
> 📘 **Info**
|
52
|
+
>
|
53
|
+
> Line item descriptions are truncated here only for display purposes.
|
54
|
+
> The full text is available in the [details](#line-items).
|
53
55
|
|
54
56
|
## Fields
|
55
57
|
Each prediction object contains a set of different fields.
|
@@ -91,11 +93,12 @@ puts result.inference.prediction.customer_name.value
|
|
91
93
|
puts result.inference.prediction.customer_address.value
|
92
94
|
```
|
93
95
|
|
94
|
-
**`
|
96
|
+
**`customer_company_registrations`** (Array<CompanyRegistration>): Customer's company registration
|
95
97
|
|
96
98
|
```ruby
|
97
99
|
result.inference.prediction.customer_company_registrations.each do |registration|
|
98
|
-
puts registration
|
100
|
+
puts registration.value
|
101
|
+
puts registration.type
|
99
102
|
end
|
100
103
|
```
|
101
104
|
|
@@ -184,14 +187,10 @@ Each object in the list contains an extra attribute:
|
|
184
187
|
|
185
188
|
* `type` (String): Type of company registration number among predefined categories.
|
186
189
|
```ruby
|
187
|
-
|
188
|
-
puts
|
189
|
-
|
190
|
-
|
191
|
-
* `value` (String): Value of the company identifier
|
192
|
-
```ruby
|
193
|
-
# Show the value of the first registration
|
194
|
-
puts result.inference.prediction.supplier_company_registrations[0].value
|
190
|
+
result.inference.prediction.supplier_company_registrations.each do |registration|
|
191
|
+
puts registration.value
|
192
|
+
puts registration.type
|
193
|
+
end
|
195
194
|
```
|
196
195
|
|
197
196
|
### Taxes
|
data/docs/ruby-passport-ocr.md
CHANGED