mindee 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -0
- data/.yardopts +0 -1
- data/CHANGELOG.md +16 -0
- data/README.md +13 -9
- data/Rakefile +9 -1
- data/bin/mindee.rb +1 -1
- 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/expense_receipts_v5.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-getting-started.md +1 -1
- data/docs/ruby-receipt-ocr.md +30 -17
- data/lib/mindee/client.rb +3 -0
- data/lib/mindee/parsing/prediction/common_fields/locale.rb +1 -1
- data/lib/mindee/parsing/prediction/eu/license_plate/license_plate_v1.rb +4 -4
- data/lib/mindee/parsing/prediction/financial_document/financial_document_v1.rb +22 -30
- data/lib/mindee/parsing/prediction/{invoice/invoice_line_item.rb → financial_document/financial_document_v1_line_item.rb} +9 -9
- data/lib/mindee/parsing/prediction/fr/bank_account_details/bank_account_details_v1.rb +6 -6
- data/lib/mindee/parsing/prediction/fr/carte_vitale/carte_vitale_v1.rb +8 -8
- data/lib/mindee/parsing/prediction/fr/id_card/id_card_v1.rb +35 -34
- data/lib/mindee/parsing/prediction/invoice/invoice_v4.rb +14 -18
- data/lib/mindee/parsing/prediction/{financial_document/invoice_line_item.rb → invoice/invoice_v4_line_item.rb} +9 -9
- data/lib/mindee/parsing/prediction/passport/passport_v1.rb +0 -63
- data/lib/mindee/parsing/prediction/proof_of_address/proof_of_address_v1.rb +36 -38
- data/lib/mindee/parsing/prediction/receipt/receipt_v5.rb +136 -0
- data/lib/mindee/parsing/prediction/receipt/receipt_v5_line_item.rb +37 -0
- data/lib/mindee/parsing/prediction/shipping_container/shipping_container_v1.rb +2 -2
- data/lib/mindee/parsing/prediction.rb +1 -0
- data/lib/mindee/version.rb +1 -1
- data/mindee.gemspec +5 -6
- metadata +32 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 508a1201e41623fdd4b7283a90f09aefbcf66582e610120547b5706017e62c6f
|
4
|
+
data.tar.gz: 552288d7cee7f8b5c38d641a991fb9864f3ebb6f3d7c5140e178ebabec082a84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a697ccd863ee69c721f8fe0199fc6321df1812a6daf9aa51031031d197ae3cd6578b4c09162ebe03cfba0008b26320533a62cd688fbc02c3acaee21488201c8b
|
7
|
+
data.tar.gz: ae97c33e5fd32bc1919b510e4057e0b3355892ca5178fc9e40d3769d55dbb41d3b10ac1b8153f4b028e36ec11d02df977299f0581fe3d3cbf8412be23f2bec33
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,25 @@
|
|
1
1
|
# Mindee Ruby API Library Changelog
|
2
2
|
|
3
|
+
## v2.2.0 - 2023-05-16
|
4
|
+
### Changes
|
5
|
+
* :sparkles: add support for Receipts v5
|
6
|
+
* :pushpin: more specific dependency pinning; update some dependencies
|
7
|
+
|
8
|
+
|
9
|
+
## v2.1.1 - 2023-04-21
|
10
|
+
### Changes
|
11
|
+
* :memo: minor docstring improvements
|
12
|
+
* :coffin: remove redundant local checks
|
13
|
+
* :memo: publish documentation
|
14
|
+
* :memo: add code samples
|
15
|
+
|
16
|
+
|
3
17
|
## v2.1.0 - 2023-01-30
|
4
18
|
### Changes
|
5
19
|
* :sparkles: Add financial document v1 support (Co-authored-by: Oriol Gual)
|
6
20
|
* :sparkles: Add Proof of Address v1 support
|
7
21
|
|
22
|
+
|
8
23
|
## v2.0.0 - 2023-01-13
|
9
24
|
### ¡Breaking Changes!
|
10
25
|
* :sparkles: add improved PDF merge system
|
@@ -22,6 +37,7 @@
|
|
22
37
|
* :white_check_mark: add testing on Ruby 3.2
|
23
38
|
* :sparkles: allow setting the request timeout from env
|
24
39
|
|
40
|
+
|
25
41
|
## v1.2.0 - 2022-12-26
|
26
42
|
### Changes
|
27
43
|
* :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
@@ -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, specifying an API key
|
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::ReceiptV5)
|
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
|
@@ -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-receipt-ocr.md
CHANGED
@@ -2,7 +2,7 @@ The Ruby OCR SDK supports the [receipt API](https://developers.mindee.com/docs/
|
|
2
2
|
|
3
3
|
Using this sample below, we are going to illustrate how to extract the data that we want using the OCR SDK.
|
4
4
|
|
5
|
-
![sample receipt](https://raw.githubusercontent.com/mindee/client-lib-test-data/main/receipt/receipt
|
5
|
+
![sample receipt](https://raw.githubusercontent.com/mindee/client-lib-test-data/main/receipt/receipt.jpg)
|
6
6
|
|
7
7
|
## Quick Start
|
8
8
|
```ruby
|
@@ -11,27 +11,41 @@ require 'mindee'
|
|
11
11
|
# Init a new client, specifying an API key
|
12
12
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
13
13
|
|
14
|
-
#
|
15
|
-
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
14
|
+
# Load a file from disk and parse it
|
15
|
+
result = mindee_client.doc_from_path('/path/to/the/file.ext')
|
16
|
+
.parse(Mindee::Prediction::ReceiptV5)
|
16
17
|
|
17
|
-
# Print a summary of the
|
18
|
+
# Print a full summary of the parsed data in RST format
|
19
|
+
# puts result
|
20
|
+
|
21
|
+
# Print the document-level parsed data
|
18
22
|
puts result.inference.prediction
|
19
23
|
```
|
20
24
|
|
21
25
|
Output:
|
22
26
|
```
|
23
|
-
:Locale: en-
|
24
|
-
:
|
25
|
-
:Category:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:Time:
|
29
|
-
:
|
30
|
-
:Taxes:
|
31
|
-
:Total
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
27
|
+
:Expense Locale: en-GB; en; GB; GBP;
|
28
|
+
:Expense Category: food
|
29
|
+
:Expense Sub Category: restaurant
|
30
|
+
:Document Type: EXPENSE RECEIPT
|
31
|
+
:Purchase Date: 2016-02-26
|
32
|
+
:Purchase Time: 15:20
|
33
|
+
:Total Amount: 10.20
|
34
|
+
:Total Excluding Taxes: 8.50
|
35
|
+
:Total Tax: 1.70
|
36
|
+
:Tip and Gratuity:
|
37
|
+
:Taxes: 1.70 20.00% VAT
|
38
|
+
:Supplier Name: CLACHAN
|
39
|
+
:Supplier Company Registrations: 232153895
|
40
|
+
232153895
|
41
|
+
:Supplier Address: 34 kingley street w1b 5qh
|
42
|
+
:Supplier Phone Number: 02074940834
|
43
|
+
:Line Items:
|
44
|
+
+--------------------------------------+----------+--------------+------------+
|
45
|
+
| Description | Quantity | Total Amount | Unit Price |
|
46
|
+
+======================================+==========+==============+============+
|
47
|
+
| Meantime Pale | 2.00 | 10.20 | |
|
48
|
+
+--------------------------------------+----------+--------------+------------+
|
35
49
|
```
|
36
50
|
|
37
51
|
## Fields
|
@@ -50,7 +64,6 @@ Depending on the field type specified, additional attributes can be extracted in
|
|
50
64
|
|
51
65
|
Using the above sample, the following are the basic fields that can be extracted:
|
52
66
|
|
53
|
-
- [Orientation](#orientation)
|
54
67
|
- [Category](#category)
|
55
68
|
- [Date](#date)
|
56
69
|
- [Locale](#locale)
|
data/lib/mindee/client.rb
CHANGED
@@ -183,6 +183,9 @@ module Mindee
|
|
183
183
|
@doc_configs[['mindee', Prediction::ReceiptV4.name]] = standard_document_config(
|
184
184
|
Prediction::ReceiptV4, 'expense_receipts', '4'
|
185
185
|
)
|
186
|
+
@doc_configs[['mindee', Prediction::ReceiptV5.name]] = standard_document_config(
|
187
|
+
Prediction::ReceiptV5, 'expense_receipts', '5'
|
188
|
+
)
|
186
189
|
@doc_configs[['mindee', Prediction::PassportV1.name]] = standard_document_config(
|
187
190
|
Prediction::PassportV1, 'passport', '1'
|
188
191
|
)
|
@@ -6,9 +6,9 @@ require_relative '../../base'
|
|
6
6
|
module Mindee
|
7
7
|
module Prediction
|
8
8
|
module EU
|
9
|
-
# License
|
9
|
+
# License Plate v1 prediction results.
|
10
10
|
class LicensePlateV1 < Prediction
|
11
|
-
#
|
11
|
+
# List of all license plates found in the image.
|
12
12
|
# @return [Array<Mindee::TextField>]
|
13
13
|
attr_reader :license_plates
|
14
14
|
|
@@ -23,9 +23,9 @@ module Mindee
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def to_s
|
26
|
-
license_plates = @license_plates.
|
26
|
+
license_plates = @license_plates.join("\n #{' ' * 16}")
|
27
27
|
out_str = String.new
|
28
|
-
out_str << "\n:License
|
28
|
+
out_str << "\n:License Plates: #{license_plates}".rstrip
|
29
29
|
out_str[1..].to_s
|
30
30
|
end
|
31
31
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative '../common_fields'
|
4
4
|
require_relative '../base'
|
5
|
-
require_relative '
|
5
|
+
require_relative 'financial_document_v1_line_item'
|
6
6
|
|
7
7
|
module Mindee
|
8
8
|
module Prediction
|
@@ -11,7 +11,7 @@ module Mindee
|
|
11
11
|
# Locale information.
|
12
12
|
# @return [Mindee::Locale]
|
13
13
|
attr_reader :locale
|
14
|
-
# The nature of the
|
14
|
+
# The nature of the document.
|
15
15
|
# @return [Mindee::TextField]
|
16
16
|
attr_reader :document_type
|
17
17
|
# The total amount with tax included.
|
@@ -23,7 +23,7 @@ module Mindee
|
|
23
23
|
# The total tax.
|
24
24
|
# @return [Mindee::AmountField]
|
25
25
|
attr_reader :total_tax
|
26
|
-
# The creation date of the
|
26
|
+
# The creation date of the document.
|
27
27
|
# @return [Mindee::DateField]
|
28
28
|
attr_reader :date
|
29
29
|
# The invoice number.
|
@@ -53,26 +53,26 @@ module Mindee
|
|
53
53
|
# The supplier's address.
|
54
54
|
# @return [Mindee::TextField]
|
55
55
|
attr_reader :supplier_address
|
56
|
-
# The payment information.
|
56
|
+
# The supplier's payment information.
|
57
57
|
# @return [Array<Mindee::PaymentDetails>]
|
58
58
|
attr_reader :supplier_payment_details
|
59
59
|
# The supplier's company registration information.
|
60
60
|
# @return [Array<Mindee::CompanyRegistration>]
|
61
61
|
attr_reader :supplier_company_registrations
|
62
62
|
# Line items details.
|
63
|
-
# @return [Array<Mindee::
|
63
|
+
# @return [Array<Mindee::FinancialDocumentV1LineItem>]
|
64
64
|
attr_reader :line_items
|
65
65
|
# Time as seen on the receipt in HH:MM format.
|
66
66
|
# @return [Mindee::TextField]
|
67
67
|
attr_reader :time
|
68
|
-
# The receipt category among predefined classes.
|
68
|
+
# The invoice or receipt category among predefined classes.
|
69
69
|
# @return [Mindee::TextField]
|
70
70
|
attr_reader :category
|
71
|
-
# The receipt sub-category among predefined classes.
|
71
|
+
# The invoice or receipt sub-category among predefined classes.
|
72
72
|
# @return [Mindee::TextField]
|
73
73
|
attr_reader :subcategory
|
74
|
-
# A classification field, that can return 4 values
|
75
|
-
#
|
74
|
+
# A classification field, that can return 4 values:
|
75
|
+
# `EXPENSE RECEIPT`, `CREDIT CARD RECEIPT`, `INVOICE`, `CREDIT NOTE`
|
76
76
|
# @return [Mindee::TextField]
|
77
77
|
attr_reader :document_type # rubocop:todo Lint/DuplicateMethods
|
78
78
|
# Total amount of tip and gratuity. Both typed and handwritten characters are supported.
|
@@ -83,7 +83,6 @@ module Mindee
|
|
83
83
|
# @param page_id [Integer, nil]
|
84
84
|
def initialize(prediction, page_id) # rubocop:todo Metrics/AbcSize
|
85
85
|
super
|
86
|
-
|
87
86
|
@time = TextField.new(prediction['time'], page_id)
|
88
87
|
@category = TextField.new(prediction['category'], page_id)
|
89
88
|
@subcategory = TextField.new(prediction['subcategory'], page_id)
|
@@ -100,7 +99,6 @@ module Mindee
|
|
100
99
|
@invoice_number = TextField.new(prediction['invoice_number'], page_id)
|
101
100
|
@supplier_name = TextField.new(prediction['supplier_name'], page_id)
|
102
101
|
@supplier_address = TextField.new(prediction['supplier_address'], page_id)
|
103
|
-
|
104
102
|
@reference_numbers = []
|
105
103
|
prediction['reference_numbers'].each do |item|
|
106
104
|
@reference_numbers.push(TextField.new(item, page_id))
|
@@ -121,14 +119,12 @@ module Mindee
|
|
121
119
|
prediction['supplier_company_registrations'].each do |item|
|
122
120
|
@supplier_company_registrations.push(CompanyRegistration.new(item, page_id))
|
123
121
|
end
|
124
|
-
|
125
122
|
@total_tax = AmountField.new(
|
126
123
|
{ value: nil, confidence: 0.0 }, page_id
|
127
124
|
)
|
128
|
-
|
129
125
|
@line_items = []
|
130
126
|
prediction['line_items'].each do |item|
|
131
|
-
@line_items.push(
|
127
|
+
@line_items.push(FinancialDocumentV1LineItem.new(item, page_id))
|
132
128
|
end
|
133
129
|
reconstruct(page_id)
|
134
130
|
end
|
@@ -153,39 +149,35 @@ module Mindee
|
|
153
149
|
out_str << "\n:Supplier address: #{@supplier_address}".rstrip
|
154
150
|
out_str << "\n:Supplier company registrations: #{supplier_company_registrations}".rstrip
|
155
151
|
out_str << "\n:Supplier payment details: #{supplier_payment_details}".rstrip
|
156
|
-
|
157
152
|
out_str << "\n:Customer name: #{@customer_name}".rstrip
|
158
153
|
out_str << "\n:Customer address: #{@customer_address}".rstrip
|
159
154
|
out_str << "\n:Customer company registrations: #{customer_company_registrations}".rstrip
|
160
|
-
|
161
155
|
out_str << "\n:Tip: #{@tip}".rstrip
|
162
|
-
|
163
156
|
out_str << "\n:Taxes: #{taxes}".rstrip
|
164
157
|
out_str << "\n:Total taxes: #{@total_tax}".rstrip
|
165
158
|
out_str << "\n:Total net: #{@total_net}".rstrip
|
166
159
|
out_str << "\n:Total amount: #{@total_amount}".rstrip
|
167
|
-
|
160
|
+
out_str << "\n:Line Items:"
|
168
161
|
out_str << line_items_to_s
|
169
|
-
|
170
162
|
out_str[1..].to_s
|
171
163
|
end
|
172
164
|
|
173
165
|
private
|
174
166
|
|
167
|
+
def line_item_separator(char)
|
168
|
+
" +#{char * 22}+#{char * 9}+#{char * 9}+#{char * 10}+#{char * 18}+#{char * 38}+"
|
169
|
+
end
|
170
|
+
|
175
171
|
def line_items_to_s
|
176
|
-
|
177
|
-
line_items = @line_items.map(&:to_s).join("\n")
|
172
|
+
return '' if @line_items.empty?
|
178
173
|
|
174
|
+
line_items = @line_items.map(&:to_s).join("\n#{line_item_separator('-')}\n ")
|
179
175
|
out_str = String.new
|
180
|
-
out_str << "\n
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
out_str << "\n#{line_item_separator}"
|
185
|
-
out_str << "\nCode QTY Price Amount Tax (Rate) Description"
|
186
|
-
out_str << "\n#{line_item_separator}"
|
187
|
-
out_str << "\n#{line_items}"
|
188
|
-
out_str << "\n#{line_item_separator}"
|
176
|
+
out_str << "\n#{line_item_separator('-')}"
|
177
|
+
out_str << "\n | Code#{' ' * 17}| QTY | Price | Amount | Tax (Rate) | Description#{' ' * 26}|"
|
178
|
+
out_str << "\n#{line_item_separator('=')}"
|
179
|
+
out_str << "\n #{line_items}"
|
180
|
+
out_str << "\n#{line_item_separator('-')}"
|
189
181
|
end
|
190
182
|
|
191
183
|
def reconstruct(page_id)
|