mindee 4.7.1 → 4.7.2
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 +5 -0
- data/lib/mindee/input/sources/local_input_source.rb +9 -1
- data/lib/mindee/product.rb +0 -1
- data/lib/mindee/version.rb +1 -1
- data/sig/mindee/input/sources/local_input_source.rbs +1 -1
- metadata +2 -15
- data/docs/code_samples/us_mail_v2_async.txt +0 -24
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2279aaa45f25ab506ab861d139c93029ddcffe5899ca448041fbbe02ef422058
|
4
|
+
data.tar.gz: 8a531ca5073b775a5b4afdb6e97f001129fb9d1aa4cf3f4f31633580cd9c16aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3b4a6fb9da9a9b8bd3d14b8b06d7c77e328c7eaa060910578f4e345ebc0a732d2b5c4b6e9117621caa1ff7b5f2633624f383833b80c8e7f81faa16236f9d1ca
|
7
|
+
data.tar.gz: 4be80490fb4f63677954c770458d9bcfdd237bb7fbd1f72fed286b3414046987c0281d6cb2867490e4261e7c423e3ee8d37a24b7e986de77bf97abfbe96950c4
|
data/CHANGELOG.md
CHANGED
@@ -141,7 +141,7 @@ module Mindee
|
|
141
141
|
# Returns the page count for a document.
|
142
142
|
# Defaults to one for images.
|
143
143
|
# @return [Integer]
|
144
|
-
def
|
144
|
+
def page_count
|
145
145
|
return 1 unless pdf?
|
146
146
|
|
147
147
|
@io_stream.seek(0)
|
@@ -149,6 +149,14 @@ module Mindee
|
|
149
149
|
pdf_processor.pages.size
|
150
150
|
end
|
151
151
|
|
152
|
+
# Returns the page count for a document.
|
153
|
+
# Defaults to one for images.
|
154
|
+
# @return [Integer]
|
155
|
+
# @deprecated Use {#page_count} instead.
|
156
|
+
def count_pages
|
157
|
+
page_count
|
158
|
+
end
|
159
|
+
|
152
160
|
# Compresses the file, according to the provided info.
|
153
161
|
# @param [Integer] quality Quality of the output file.
|
154
162
|
# @param [Integer, nil] max_width Maximum width (Ignored for PDFs).
|
data/lib/mindee/product.rb
CHANGED
@@ -29,5 +29,4 @@ require_relative 'product/resume/resume_v1'
|
|
29
29
|
require_relative 'product/universal/universal'
|
30
30
|
require_relative 'product/us/bank_check/bank_check_v1'
|
31
31
|
require_relative 'product/us/healthcare_card/healthcare_card_v1'
|
32
|
-
require_relative 'product/us/us_mail/us_mail_v2'
|
33
32
|
require_relative 'product/us/us_mail/us_mail_v3'
|
data/lib/mindee/version.rb
CHANGED
@@ -14,12 +14,12 @@ module Mindee
|
|
14
14
|
|
15
15
|
def logger: () -> Logger
|
16
16
|
|
17
|
-
|
18
17
|
def rescue_broken_pdf: (untyped) -> void
|
19
18
|
def pdf?: -> bool
|
20
19
|
def apply_page_options: (PageOptions) -> StringIO?
|
21
20
|
def process_pdf: (PageOptions) -> StringIO?
|
22
21
|
def read_contents: (?close: bool) -> [String?, Hash[:filename, String]]
|
22
|
+
def page_count: -> Integer
|
23
23
|
def count_pages: -> Integer
|
24
24
|
def write_to_file: (String?) -> void
|
25
25
|
def compress!: (?quality: Integer, ?max_width: Integer?, ?max_height: Integer?, ?force_source_text: bool, ?disable_source_text: bool) -> Integer
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mindee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.7.
|
4
|
+
version: 4.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindee, SA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -244,7 +244,6 @@ files:
|
|
244
244
|
- docs/code_samples/payslip_fra_v3_async.txt
|
245
245
|
- docs/code_samples/resume_v1_async.txt
|
246
246
|
- docs/code_samples/us_healthcare_cards_v1_async.txt
|
247
|
-
- docs/code_samples/us_mail_v2_async.txt
|
248
247
|
- docs/code_samples/us_mail_v3_async.txt
|
249
248
|
- docs/code_samples/workflow_execution.txt
|
250
249
|
- docs/code_samples/workflow_polling.txt
|
@@ -554,12 +553,6 @@ files:
|
|
554
553
|
- lib/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rb
|
555
554
|
- lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb
|
556
555
|
- lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb
|
557
|
-
- lib/mindee/product/us/us_mail/us_mail_v2.rb
|
558
|
-
- lib/mindee/product/us/us_mail/us_mail_v2_document.rb
|
559
|
-
- lib/mindee/product/us/us_mail/us_mail_v2_page.rb
|
560
|
-
- lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb
|
561
|
-
- lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb
|
562
|
-
- lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb
|
563
556
|
- lib/mindee/product/us/us_mail/us_mail_v3.rb
|
564
557
|
- lib/mindee/product/us/us_mail/us_mail_v3_document.rb
|
565
558
|
- lib/mindee/product/us/us_mail/us_mail_v3_page.rb
|
@@ -825,12 +818,6 @@ files:
|
|
825
818
|
- sig/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rbs
|
826
819
|
- sig/mindee/product/us/healthcare_card/healthcare_card_v1_document.rbs
|
827
820
|
- sig/mindee/product/us/healthcare_card/healthcare_card_v1_page.rbs
|
828
|
-
- sig/mindee/product/us/us_mail/us_mail_v2.rbs
|
829
|
-
- sig/mindee/product/us/us_mail/us_mail_v2_document.rbs
|
830
|
-
- sig/mindee/product/us/us_mail/us_mail_v2_page.rbs
|
831
|
-
- sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs
|
832
|
-
- sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs
|
833
|
-
- sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs
|
834
821
|
- sig/mindee/product/us/us_mail/us_mail_v3.rbs
|
835
822
|
- sig/mindee/product/us/us_mail/us_mail_v3_document.rbs
|
836
823
|
- sig/mindee/product/us/us_mail/us_mail_v3_page.rbs
|
@@ -1,24 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Install the Ruby client library by running:
|
3
|
-
# gem install mindee
|
4
|
-
#
|
5
|
-
|
6
|
-
require 'mindee'
|
7
|
-
|
8
|
-
# Init a new client
|
9
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
10
|
-
|
11
|
-
# Load a file from disk
|
12
|
-
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
13
|
-
|
14
|
-
# Parse the file
|
15
|
-
result = mindee_client.parse(
|
16
|
-
input_source,
|
17
|
-
Mindee::Product::US::UsMail::UsMailV2
|
18
|
-
)
|
19
|
-
|
20
|
-
# Print a full summary of the parsed data in RST format
|
21
|
-
puts result.document
|
22
|
-
|
23
|
-
# Print the document-level parsed data
|
24
|
-
# puts result.document.inference.prediction
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../parsing'
|
4
|
-
require_relative 'us_mail_v2_document'
|
5
|
-
require_relative 'us_mail_v2_page'
|
6
|
-
|
7
|
-
module Mindee
|
8
|
-
module Product
|
9
|
-
module US
|
10
|
-
# US Mail module.
|
11
|
-
module UsMail
|
12
|
-
# US Mail API version 2 inference prediction.
|
13
|
-
class UsMailV2 < Mindee::Parsing::Common::Inference
|
14
|
-
@endpoint_name = 'us_mail'
|
15
|
-
@endpoint_version = '2'
|
16
|
-
@has_async = true
|
17
|
-
@has_sync = false
|
18
|
-
|
19
|
-
# @param prediction [Hash]
|
20
|
-
def initialize(prediction)
|
21
|
-
super
|
22
|
-
@prediction = UsMailV2Document.new(prediction['prediction'], nil)
|
23
|
-
@pages = []
|
24
|
-
prediction['pages'].each do |page|
|
25
|
-
@pages.push(UsMailV2Page.new(page))
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class << self
|
30
|
-
# Name of the endpoint for this product.
|
31
|
-
# @return [String]
|
32
|
-
attr_reader :endpoint_name
|
33
|
-
# Version for this product.
|
34
|
-
# @return [String]
|
35
|
-
attr_reader :endpoint_version
|
36
|
-
# Whether this product has access to an asynchronous endpoint.
|
37
|
-
# @return [bool]
|
38
|
-
attr_reader :has_async
|
39
|
-
# Whether this product has access to synchronous endpoint.
|
40
|
-
# @return [bool]
|
41
|
-
attr_reader :has_sync
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../parsing'
|
4
|
-
require_relative 'us_mail_v2_sender_address'
|
5
|
-
require_relative 'us_mail_v2_recipient_addresses'
|
6
|
-
|
7
|
-
module Mindee
|
8
|
-
module Product
|
9
|
-
module US
|
10
|
-
module UsMail
|
11
|
-
# US Mail API version 2.0 document data.
|
12
|
-
class UsMailV2Document < Mindee::Parsing::Common::Prediction
|
13
|
-
include Mindee::Parsing::Standard
|
14
|
-
# The addresses of the recipients.
|
15
|
-
# @return [Mindee::Product::US::UsMail::UsMailV2RecipientAddresses]
|
16
|
-
attr_reader :recipient_addresses
|
17
|
-
# The names of the recipients.
|
18
|
-
# @return [Array<Mindee::Parsing::Standard::StringField>]
|
19
|
-
attr_reader :recipient_names
|
20
|
-
# The address of the sender.
|
21
|
-
# @return [Mindee::Product::US::UsMail::UsMailV2SenderAddress]
|
22
|
-
attr_reader :sender_address
|
23
|
-
# The name of the sender.
|
24
|
-
# @return [Mindee::Parsing::Standard::StringField]
|
25
|
-
attr_reader :sender_name
|
26
|
-
|
27
|
-
# @param prediction [Hash]
|
28
|
-
# @param page_id [Integer, nil]
|
29
|
-
def initialize(prediction, page_id)
|
30
|
-
super
|
31
|
-
@recipient_addresses = Product::US::UsMail::UsMailV2RecipientAddresses.new(
|
32
|
-
prediction['recipient_addresses'], page_id
|
33
|
-
)
|
34
|
-
@recipient_names = [] # : Array[Parsing::Standard::StringField]
|
35
|
-
prediction['recipient_names'].each do |item|
|
36
|
-
@recipient_names.push(Parsing::Standard::StringField.new(item, page_id))
|
37
|
-
end
|
38
|
-
@sender_address = Product::US::UsMail::UsMailV2SenderAddress.new(
|
39
|
-
prediction['sender_address'],
|
40
|
-
page_id
|
41
|
-
)
|
42
|
-
@sender_name = Parsing::Standard::StringField.new(
|
43
|
-
prediction['sender_name'],
|
44
|
-
page_id
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
# @return [String]
|
49
|
-
def to_s
|
50
|
-
sender_address = @sender_address.to_s
|
51
|
-
recipient_names = @recipient_names.join("\n #{' ' * 17}")
|
52
|
-
recipient_addresses = recipient_addresses_to_s
|
53
|
-
out_str = String.new
|
54
|
-
out_str << "\n:Sender Name: #{@sender_name}".rstrip
|
55
|
-
out_str << "\n:Sender Address:"
|
56
|
-
out_str << sender_address
|
57
|
-
out_str << "\n:Recipient Names: #{recipient_names}".rstrip
|
58
|
-
out_str << "\n:Recipient Addresses:"
|
59
|
-
out_str << recipient_addresses
|
60
|
-
out_str[1..].to_s
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
# @param char [String]
|
66
|
-
# @return [String]
|
67
|
-
def recipient_addresses_separator(char)
|
68
|
-
out_str = String.new
|
69
|
-
out_str << ' '
|
70
|
-
out_str << "+#{char * 17}"
|
71
|
-
out_str << "+#{char * 37}"
|
72
|
-
out_str << "+#{char * 19}"
|
73
|
-
out_str << "+#{char * 13}"
|
74
|
-
out_str << "+#{char * 24}"
|
75
|
-
out_str << "+#{char * 7}"
|
76
|
-
out_str << "+#{char * 27}"
|
77
|
-
out_str << '+'
|
78
|
-
out_str
|
79
|
-
end
|
80
|
-
|
81
|
-
# @return [String]
|
82
|
-
def recipient_addresses_to_s
|
83
|
-
return '' if @recipient_addresses.empty?
|
84
|
-
|
85
|
-
line_items = @recipient_addresses.map(&:to_table_line).join("\n#{recipient_addresses_separator('-')}\n ")
|
86
|
-
out_str = String.new
|
87
|
-
out_str << "\n#{recipient_addresses_separator('-')}"
|
88
|
-
out_str << "\n |"
|
89
|
-
out_str << ' City |'
|
90
|
-
out_str << ' Complete Address |'
|
91
|
-
out_str << ' Is Address Change |'
|
92
|
-
out_str << ' Postal Code |'
|
93
|
-
out_str << ' Private Mailbox Number |'
|
94
|
-
out_str << ' State |'
|
95
|
-
out_str << ' Street |'
|
96
|
-
out_str << "\n#{recipient_addresses_separator('=')}"
|
97
|
-
out_str << "\n #{line_items}"
|
98
|
-
out_str << "\n#{recipient_addresses_separator('-')}"
|
99
|
-
out_str
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../parsing'
|
4
|
-
require_relative 'us_mail_v2_document'
|
5
|
-
|
6
|
-
module Mindee
|
7
|
-
module Product
|
8
|
-
module US
|
9
|
-
module UsMail
|
10
|
-
# US Mail API version 2.0 page data.
|
11
|
-
class UsMailV2Page < Mindee::Parsing::Common::Page
|
12
|
-
# @param prediction [Hash]
|
13
|
-
def initialize(prediction)
|
14
|
-
super
|
15
|
-
@prediction = if prediction['prediction'].empty?
|
16
|
-
nil
|
17
|
-
else
|
18
|
-
UsMailV2PagePrediction.new(
|
19
|
-
prediction['prediction'],
|
20
|
-
prediction['id']
|
21
|
-
)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# US Mail V2 page prediction.
|
27
|
-
class UsMailV2PagePrediction < UsMailV2Document
|
28
|
-
# @return [String]
|
29
|
-
def to_s
|
30
|
-
out_str = String.new
|
31
|
-
out_str << "\n#{super}"
|
32
|
-
out_str
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../parsing'
|
4
|
-
|
5
|
-
module Mindee
|
6
|
-
module Product
|
7
|
-
module US
|
8
|
-
module UsMail
|
9
|
-
# The addresses of the recipients.
|
10
|
-
class UsMailV2RecipientAddress < Mindee::Parsing::Standard::FeatureField
|
11
|
-
include Mindee::Parsing::Standard
|
12
|
-
# The city of the recipient's address.
|
13
|
-
# @return [String]
|
14
|
-
attr_reader :city
|
15
|
-
# The complete address of the recipient.
|
16
|
-
# @return [String]
|
17
|
-
attr_reader :complete
|
18
|
-
# Indicates if the recipient's address is a change of address.
|
19
|
-
# @return [bool]
|
20
|
-
attr_reader :is_address_change
|
21
|
-
# The postal code of the recipient's address.
|
22
|
-
# @return [String]
|
23
|
-
attr_reader :postal_code
|
24
|
-
# The private mailbox number of the recipient's address.
|
25
|
-
# @return [String]
|
26
|
-
attr_reader :private_mailbox_number
|
27
|
-
# Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.
|
28
|
-
# @return [String]
|
29
|
-
attr_reader :state
|
30
|
-
# The street of the recipient's address.
|
31
|
-
# @return [String]
|
32
|
-
attr_reader :street
|
33
|
-
|
34
|
-
# @param prediction [Hash]
|
35
|
-
# @param page_id [Integer, nil]
|
36
|
-
def initialize(prediction, page_id)
|
37
|
-
super
|
38
|
-
@city = prediction['city']
|
39
|
-
@complete = prediction['complete']
|
40
|
-
@is_address_change = prediction['is_address_change']
|
41
|
-
@postal_code = prediction['postal_code']
|
42
|
-
@private_mailbox_number = prediction['private_mailbox_number']
|
43
|
-
@state = prediction['state']
|
44
|
-
@street = prediction['street']
|
45
|
-
@page_id = page_id
|
46
|
-
end
|
47
|
-
|
48
|
-
# @return [Hash]
|
49
|
-
def printable_values
|
50
|
-
printable = {}
|
51
|
-
printable[:city] = format_for_display(@city)
|
52
|
-
printable[:complete] = format_for_display(@complete)
|
53
|
-
printable[:is_address_change] = format_for_display(@is_address_change)
|
54
|
-
printable[:postal_code] = format_for_display(@postal_code)
|
55
|
-
printable[:private_mailbox_number] = format_for_display(@private_mailbox_number)
|
56
|
-
printable[:state] = format_for_display(@state)
|
57
|
-
printable[:street] = format_for_display(@street)
|
58
|
-
printable
|
59
|
-
end
|
60
|
-
|
61
|
-
# @return [Hash]
|
62
|
-
def table_printable_values
|
63
|
-
printable = {}
|
64
|
-
printable[:city] = format_for_display(@city, 15)
|
65
|
-
printable[:complete] = format_for_display(@complete, 35)
|
66
|
-
printable[:is_address_change] = format_for_display(@is_address_change, nil)
|
67
|
-
printable[:postal_code] = format_for_display(@postal_code, nil)
|
68
|
-
printable[:private_mailbox_number] = format_for_display(@private_mailbox_number, nil)
|
69
|
-
printable[:state] = format_for_display(@state, nil)
|
70
|
-
printable[:street] = format_for_display(@street, 25)
|
71
|
-
printable
|
72
|
-
end
|
73
|
-
|
74
|
-
# @return [String]
|
75
|
-
def to_table_line
|
76
|
-
printable = table_printable_values
|
77
|
-
out_str = String.new
|
78
|
-
out_str << format('| %- 16s', printable[:city])
|
79
|
-
out_str << format('| %- 36s', printable[:complete])
|
80
|
-
out_str << format('| %- 18s', printable[:is_address_change])
|
81
|
-
out_str << format('| %- 12s', printable[:postal_code])
|
82
|
-
out_str << format('| %- 23s', printable[:private_mailbox_number])
|
83
|
-
out_str << format('| %- 6s', printable[:state])
|
84
|
-
out_str << format('| %- 26s', printable[:street])
|
85
|
-
out_str << '|'
|
86
|
-
end
|
87
|
-
|
88
|
-
# @return [String]
|
89
|
-
def to_s
|
90
|
-
printable = printable_values
|
91
|
-
out_str = String.new
|
92
|
-
out_str << "\n :City: #{printable[:city]}"
|
93
|
-
out_str << "\n :Complete Address: #{printable[:complete]}"
|
94
|
-
out_str << "\n :Is Address Change: #{printable[:is_address_change]}"
|
95
|
-
out_str << "\n :Postal Code: #{printable[:postal_code]}"
|
96
|
-
out_str << "\n :Private Mailbox Number: #{printable[:private_mailbox_number]}"
|
97
|
-
out_str << "\n :State: #{printable[:state]}"
|
98
|
-
out_str << "\n :Street: #{printable[:street]}"
|
99
|
-
out_str
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'us_mail_v2_sender_address'
|
4
|
-
require_relative 'us_mail_v2_recipient_address'
|
5
|
-
|
6
|
-
module Mindee
|
7
|
-
module Product
|
8
|
-
module US
|
9
|
-
module UsMail
|
10
|
-
# The addresses of the recipients.
|
11
|
-
class UsMailV2RecipientAddresses < Array
|
12
|
-
# Entries.
|
13
|
-
# @return [Array<UsMailV2RecipientAddress>]
|
14
|
-
attr_reader :entries
|
15
|
-
|
16
|
-
# @param prediction [Array]
|
17
|
-
# @param page_id [Integer, nil]
|
18
|
-
def initialize(prediction, page_id)
|
19
|
-
entries = prediction.map do |entry|
|
20
|
-
UsMail::UsMailV2RecipientAddress.new(entry, page_id)
|
21
|
-
end
|
22
|
-
super(entries)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Creates a line of rST table-compliant string separators.
|
26
|
-
# @param char [String] Character to use as a separator.
|
27
|
-
# @return [String]
|
28
|
-
def self.line_items_separator(char)
|
29
|
-
out_str = String.new
|
30
|
-
out_str << "+#{char * 17}"
|
31
|
-
out_str << "+#{char * 37}"
|
32
|
-
out_str << "+#{char * 19}"
|
33
|
-
out_str << "+#{char * 13}"
|
34
|
-
out_str << "+#{char * 24}"
|
35
|
-
out_str << "+#{char * 7}"
|
36
|
-
out_str << "+#{char * 27}"
|
37
|
-
out_str
|
38
|
-
end
|
39
|
-
|
40
|
-
# @return [String]
|
41
|
-
def to_s
|
42
|
-
return '' if empty?
|
43
|
-
|
44
|
-
lines = map do |entry|
|
45
|
-
"\n #{entry.to_table_line}\n#{self.class.line_items_separator('-')}"
|
46
|
-
end.join
|
47
|
-
out_str = String.new
|
48
|
-
out_str << "\n#{self.class.line_items_separator('-')}\n "
|
49
|
-
out_str << ' | City '
|
50
|
-
out_str << ' | Complete Address '
|
51
|
-
out_str << ' | Is Address Change'
|
52
|
-
out_str << ' | Postal Code'
|
53
|
-
out_str << ' | Private Mailbox Number'
|
54
|
-
out_str << ' | State'
|
55
|
-
out_str << ' | Street '
|
56
|
-
out_str << " |\n#{self.class.line_items_separator('=')}"
|
57
|
-
out_str + lines
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../parsing'
|
4
|
-
|
5
|
-
module Mindee
|
6
|
-
module Product
|
7
|
-
module US
|
8
|
-
module UsMail
|
9
|
-
# The address of the sender.
|
10
|
-
class UsMailV2SenderAddress < Mindee::Parsing::Standard::FeatureField
|
11
|
-
include Mindee::Parsing::Standard
|
12
|
-
# The city of the sender's address.
|
13
|
-
# @return [String]
|
14
|
-
attr_reader :city
|
15
|
-
# The complete address of the sender.
|
16
|
-
# @return [String]
|
17
|
-
attr_reader :complete
|
18
|
-
# The postal code of the sender's address.
|
19
|
-
# @return [String]
|
20
|
-
attr_reader :postal_code
|
21
|
-
# Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.
|
22
|
-
# @return [String]
|
23
|
-
attr_reader :state
|
24
|
-
# The street of the sender's address.
|
25
|
-
# @return [String]
|
26
|
-
attr_reader :street
|
27
|
-
|
28
|
-
# @param prediction [Hash]
|
29
|
-
# @param page_id [Integer, nil]
|
30
|
-
def initialize(prediction, page_id)
|
31
|
-
super
|
32
|
-
@city = prediction['city']
|
33
|
-
@complete = prediction['complete']
|
34
|
-
@postal_code = prediction['postal_code']
|
35
|
-
@state = prediction['state']
|
36
|
-
@street = prediction['street']
|
37
|
-
@page_id = page_id
|
38
|
-
end
|
39
|
-
|
40
|
-
# @return [Hash]
|
41
|
-
def printable_values
|
42
|
-
printable = {}
|
43
|
-
printable[:city] = format_for_display(@city)
|
44
|
-
printable[:complete] = format_for_display(@complete)
|
45
|
-
printable[:postal_code] = format_for_display(@postal_code)
|
46
|
-
printable[:state] = format_for_display(@state)
|
47
|
-
printable[:street] = format_for_display(@street)
|
48
|
-
printable
|
49
|
-
end
|
50
|
-
|
51
|
-
# @return [String]
|
52
|
-
def to_s
|
53
|
-
printable = printable_values
|
54
|
-
out_str = String.new
|
55
|
-
out_str << "\n :City: #{printable[:city]}"
|
56
|
-
out_str << "\n :Complete Address: #{printable[:complete]}"
|
57
|
-
out_str << "\n :Postal Code: #{printable[:postal_code]}"
|
58
|
-
out_str << "\n :State: #{printable[:state]}"
|
59
|
-
out_str << "\n :Street: #{printable[:street]}"
|
60
|
-
out_str
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# lib/mindee/product/../us_mail/us_mail_v2_document.rb
|
2
|
-
|
3
|
-
module Mindee
|
4
|
-
module Product
|
5
|
-
module US
|
6
|
-
module UsMail
|
7
|
-
class UsMailV2Document < Parsing::Common::Prediction
|
8
|
-
def initialize: (Hash[String | Symbol, untyped], Integer?) -> void
|
9
|
-
def recipient_addresses: -> (Product::US::UsMail::UsMailV2RecipientAddresses)
|
10
|
-
def recipient_names: -> (Array[Parsing::Standard::StringField])
|
11
|
-
def sender_address: -> (Product::US::UsMail::UsMailV2SenderAddress)
|
12
|
-
def sender_name: -> (Parsing::Standard::StringField)
|
13
|
-
def recipient_addresses_separator: (String) -> String
|
14
|
-
def recipient_addresses_to_s: -> String
|
15
|
-
def to_s: -> String
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# lib/mindee/product/../us_mail/us_mail_v2_page.rb
|
2
|
-
|
3
|
-
module Mindee
|
4
|
-
module Product
|
5
|
-
module US
|
6
|
-
module UsMail
|
7
|
-
class UsMailV2Page < Parsing::Common::Page
|
8
|
-
def initialize: (Hash[String | Symbol, untyped]) -> void
|
9
|
-
end
|
10
|
-
class UsMailV2PagePrediction < UsMailV2Document
|
11
|
-
def initialize: (Hash[String | Symbol, untyped], Integer?) -> void
|
12
|
-
def to_s: -> String
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Mindee
|
2
|
-
module Product
|
3
|
-
module US
|
4
|
-
module UsMail
|
5
|
-
class UsMailV2RecipientAddress < Parsing::Standard::FeatureField
|
6
|
-
def initialize: (Hash[String | Symbol, untyped], Integer?) -> void
|
7
|
-
def city: -> String
|
8
|
-
def complete: -> String
|
9
|
-
def is_address_change: -> bool
|
10
|
-
def postal_code: -> String
|
11
|
-
def private_mailbox_number: -> String
|
12
|
-
def state: -> String
|
13
|
-
def street: -> String
|
14
|
-
def printable_values: -> Hash[String | Symbol, untyped]
|
15
|
-
def table_printable_values: -> Hash[String | Symbol, untyped]
|
16
|
-
def to_table_line: -> String
|
17
|
-
def to_s: -> String
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mindee
|
4
|
-
module Product
|
5
|
-
module US
|
6
|
-
module UsMail
|
7
|
-
class UsMailV2RecipientAddresses < Array[UsMailV2RecipientAddress]
|
8
|
-
def initialize: (Array[untyped], Integer?) -> void
|
9
|
-
def self.line_items_separator: (String) -> String
|
10
|
-
def to_s: -> String
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Mindee
|
2
|
-
module Product
|
3
|
-
module US
|
4
|
-
module UsMail
|
5
|
-
class UsMailV2SenderAddress < Parsing::Standard::FeatureField
|
6
|
-
def initialize: (Hash[String | Symbol, untyped], Integer?) -> void
|
7
|
-
def city: -> String
|
8
|
-
def complete: -> String
|
9
|
-
def postal_code: -> String
|
10
|
-
def state: -> String
|
11
|
-
def street: -> String
|
12
|
-
def printable_values: -> Hash[String | Symbol, untyped]
|
13
|
-
def to_s: -> String
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|