mindee 4.5.0 → 4.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32670ffa1c3f59d5dfb573f0543ef36e80e79341acacdcb5722249425e775fa9
4
- data.tar.gz: 6e3c47dad7eeacae2b6d06277deda1e2e9e90903e83883263021e306920e99f0
3
+ metadata.gz: c37efc128220eca42a9c5af127911697d47bd4179166d9faec47f04988221d4d
4
+ data.tar.gz: da2158c80baa262b083baf4696a5d5f2d6b4226999713262419a4c98165cbd80
5
5
  SHA512:
6
- metadata.gz: 6324e2e4f0b75435fcb5baade6dbad8fb693de5cc74fff3171f53598d791486a4043826bea965ee79c58cf3988d0d69c449240f3607ec2a201c79b14f0dcdb2d
7
- data.tar.gz: 6394379b7ea271aba332256587ba406b03c3230a8647fed74d57ef474436e9b0b729be902cc60d7ee8be1ae9913f2173673c62c8f7e31383802c25bffd2d112a
6
+ metadata.gz: d5c02591130934ad5dcd7e6a87a22e753f4a3cf7bed31a0913c9f4296cc5ed4f741d085267a59d171d6e7146b34542878ae03ca920060ec9ef2e113c9bbd6f74
7
+ data.tar.gz: 6ba9a4dee2c426885452d19805bfd1582ecf76f0902c420d32cc6c7521085e50a2eb5c8ec7368a820612ae425ae37bdf53487df486d29275a534c87cfbc93f3f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Mindee Ruby API Library Changelog
2
2
 
3
+ ## v4.6.0 - 2025-06-03
4
+ ### Changes
5
+ * :sparkles: add support for address fields
6
+
7
+
3
8
  ## v4.5.0 - 2025-05-27
4
9
  ### Changes
5
10
  * :sparkles: add support for Financial Document v1.14
@@ -224,6 +224,21 @@ A typical `Field` object will have the following attributes:
224
224
  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.
225
225
 
226
226
 
227
+ ### AddressField
228
+ Aside from the basic `BaseField` attributes, the address field `AddressField` also implements the following:
229
+
230
+ * **street_number** (`String`): String representation of the street number. Can be `nil`.
231
+ * **street_name** (`String`): Name of the street. Can be `nil`.
232
+ * **po_box** (`String`): String representation of the PO Box number. Can be `nil`.
233
+ * **address_complement** (`String`): Address complement. Can be `nil`.
234
+ * **city** (`String`): City name. Can be `nil`.
235
+ * **postal_code** (`String`): String representation of the postal code. Can be `nil`.
236
+ * **state** (`String`): State name. Can be `nil`.
237
+ * **country** (`String`): Country name. Can be `nil`.
238
+
239
+ Note: The `value` field of an AddressField should be a concatenation of the rest of the values.
240
+
241
+
227
242
  ### Amount Field
228
243
  The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
229
244
 
@@ -304,7 +319,7 @@ A `FinancialDocumentV1LineItem` implements the following attributes:
304
319
  The following fields are extracted for Financial Document V1:
305
320
 
306
321
  ## Billing Address
307
- **billing_address** ([StringField](#string-field)): The customer's address used for billing.
322
+ **billing_address** ([AddressField](#address-field)): The customer's address used for billing.
308
323
 
309
324
  ```rb
310
325
  puts result.document.inference.prediction.billing_address.value
@@ -331,7 +346,7 @@ puts result.document.inference.prediction.category.value
331
346
  ```
332
347
 
333
348
  ## Customer Address
334
- **customer_address** ([StringField](#string-field)): The address of the customer.
349
+ **customer_address** ([AddressField](#address-field)): The address of the customer.
335
350
 
336
351
  ```rb
337
352
  puts result.document.inference.prediction.customer_address.value
@@ -466,7 +481,7 @@ end
466
481
  ```
467
482
 
468
483
  ## Shipping Address
469
- **shipping_address** ([StringField](#string-field)): The customer's address used for shipping.
484
+ **shipping_address** ([AddressField](#address-field)): The customer's address used for shipping.
470
485
 
471
486
  ```rb
472
487
  puts result.document.inference.prediction.shipping_address.value
@@ -497,7 +512,7 @@ puts result.document.inference.prediction.subcategory.value
497
512
  ```
498
513
 
499
514
  ## Supplier Address
500
- **supplier_address** ([StringField](#string-field)): The address of the supplier or merchant.
515
+ **supplier_address** ([AddressField](#address-field)): The address of the supplier or merchant.
501
516
 
502
517
  ```rb
503
518
  puts result.document.inference.prediction.supplier_address.value
@@ -216,6 +216,21 @@ A typical `Field` object will have the following attributes:
216
216
  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.
217
217
 
218
218
 
219
+ ### AddressField
220
+ Aside from the basic `BaseField` attributes, the address field `AddressField` also implements the following:
221
+
222
+ * **street_number** (`String`): String representation of the street number. Can be `nil`.
223
+ * **street_name** (`String`): Name of the street. Can be `nil`.
224
+ * **po_box** (`String`): String representation of the PO Box number. Can be `nil`.
225
+ * **address_complement** (`String`): Address complement. Can be `nil`.
226
+ * **city** (`String`): City name. Can be `nil`.
227
+ * **postal_code** (`String`): String representation of the postal code. Can be `nil`.
228
+ * **state** (`String`): State name. Can be `nil`.
229
+ * **country** (`String`): Country name. Can be `nil`.
230
+
231
+ Note: The `value` field of an AddressField should be a concatenation of the rest of the values.
232
+
233
+
219
234
  ### Amount Field
220
235
  The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
221
236
 
@@ -296,7 +311,7 @@ A `InvoiceV4LineItem` implements the following attributes:
296
311
  The following fields are extracted for Invoice V4:
297
312
 
298
313
  ## Billing Address
299
- **billing_address** ([StringField](#string-field)): The customer billing address.
314
+ **billing_address** ([AddressField](#address-field)): The customer billing address.
300
315
 
301
316
  ```rb
302
317
  puts result.document.inference.prediction.billing_address.value
@@ -322,7 +337,7 @@ puts result.document.inference.prediction.category.value
322
337
  ```
323
338
 
324
339
  ## Customer Address
325
- **customer_address** ([StringField](#string-field)): The address of the customer.
340
+ **customer_address** ([AddressField](#address-field)): The address of the customer.
326
341
 
327
342
  ```rb
328
343
  puts result.document.inference.prediction.customer_address.value
@@ -441,7 +456,7 @@ end
441
456
  ```
442
457
 
443
458
  ## Shipping Address
444
- **shipping_address** ([StringField](#string-field)): Customer's delivery address.
459
+ **shipping_address** ([AddressField](#address-field)): Customer's delivery address.
445
460
 
446
461
  ```rb
447
462
  puts result.document.inference.prediction.shipping_address.value
@@ -472,7 +487,7 @@ puts result.document.inference.prediction.subcategory.value
472
487
  ```
473
488
 
474
489
  ## Supplier Address
475
- **supplier_address** ([StringField](#string-field)): The address of the supplier or merchant.
490
+ **supplier_address** ([AddressField](#address-field)): The address of the supplier or merchant.
476
491
 
477
492
  ```rb
478
493
  puts result.document.inference.prediction.supplier_address.value
@@ -53,7 +53,7 @@ module Mindee
53
53
  out_str << "\n:Product: #{@product.name} v#{@product.version}"
54
54
  out_str << "\n:Rotation applied: #{is_rotation_applied}"
55
55
  out_str << "\n\nPrediction\n=========="
56
- out_str << "\n#{@prediction.to_s.size.positive? ? "#{@prediction}\n" : ''}"
56
+ out_str << "\n#{"#{@prediction}\n" if @prediction.to_s.size.positive?}"
57
57
  if @pages.any? { |page| !page.prediction.nil? }
58
58
  out_str << "\nPage Predictions\n================\n\n"
59
59
  out_str << @pages.map(&:to_s).join("\n\n")
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'string_field'
4
+
5
+ module Mindee
6
+ module Parsing
7
+ module Standard
8
+ # Represents physical-address information.
9
+ class AddressField < Mindee::Parsing::Standard::StringField
10
+ # Street number
11
+ # @return [String, nil]
12
+ attr_reader :street_number
13
+ # Street name
14
+ # @return [String, nil]
15
+ attr_reader :street_name
16
+ # PO Box number
17
+ # @return [String, nil]
18
+ attr_reader :po_box
19
+ # Address complement
20
+ # @return [String, nil]
21
+ attr_reader :address_complement
22
+ # City name.
23
+ # @return [String, nil]
24
+ attr_reader :city
25
+ # Postal or ZIP code.
26
+ # @return [String, nil]
27
+ attr_reader :postal_code
28
+ # State, province or region.
29
+ # @return [String, nil]
30
+ attr_reader :state
31
+ # Country.
32
+ # @return [String, nil]
33
+ attr_reader :country
34
+
35
+ def initialize(prediction, page_id = nil, reconstructed: false)
36
+ super
37
+ @street_number = prediction['street_number']
38
+ @street_name = prediction['street_name']
39
+ @po_box = prediction['po_box']
40
+ @address_complement = prediction['address_complement']
41
+ @city = prediction['city']
42
+ @postal_code = prediction['postal_code']
43
+ @state = prediction['state']
44
+ @country = prediction['country']
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'standard/address_field'
3
4
  require_relative 'standard/amount_field'
4
5
  require_relative 'standard/base_field'
5
6
  require_relative 'standard/boolean_field'
@@ -95,7 +95,7 @@ module Mindee
95
95
  end
96
96
 
97
97
  def handle_default_field(name, value)
98
- @all_values[name] = value.nil? ? nil : value.to_s
98
+ @all_values[name] = value&.to_s
99
99
  end
100
100
  end
101
101
 
@@ -10,13 +10,13 @@ module Mindee
10
10
  class FinancialDocumentV1Document < Mindee::Parsing::Common::Prediction
11
11
  include Mindee::Parsing::Standard
12
12
  # The customer's address used for billing.
13
- # @return [Mindee::Parsing::Standard::StringField]
13
+ # @return [Mindee::Parsing::Standard::AddressField]
14
14
  attr_reader :billing_address
15
15
  # The purchase category.
16
16
  # @return [Mindee::Parsing::Standard::ClassificationField]
17
17
  attr_reader :category
18
18
  # The address of the customer.
19
- # @return [Mindee::Parsing::Standard::StringField]
19
+ # @return [Mindee::Parsing::Standard::AddressField]
20
20
  attr_reader :customer_address
21
21
  # List of company registration numbers associated to the customer.
22
22
  # @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
@@ -65,13 +65,13 @@ module Mindee
65
65
  # @return [Array<Mindee::Parsing::Standard::StringField>]
66
66
  attr_reader :reference_numbers
67
67
  # The customer's address used for shipping.
68
- # @return [Mindee::Parsing::Standard::StringField]
68
+ # @return [Mindee::Parsing::Standard::AddressField]
69
69
  attr_reader :shipping_address
70
70
  # The purchase subcategory for transport, food and shooping.
71
71
  # @return [Mindee::Parsing::Standard::ClassificationField]
72
72
  attr_reader :subcategory
73
73
  # The address of the supplier or merchant.
74
- # @return [Mindee::Parsing::Standard::StringField]
74
+ # @return [Mindee::Parsing::Standard::AddressField]
75
75
  attr_reader :supplier_address
76
76
  # List of company registration numbers associated to the supplier.
77
77
  # @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
@@ -114,7 +114,7 @@ module Mindee
114
114
  # @param page_id [Integer, nil]
115
115
  def initialize(prediction, page_id)
116
116
  super
117
- @billing_address = Parsing::Standard::StringField.new(
117
+ @billing_address = Parsing::Standard::AddressField.new(
118
118
  prediction['billing_address'],
119
119
  page_id
120
120
  )
@@ -122,7 +122,7 @@ module Mindee
122
122
  prediction['category'],
123
123
  page_id
124
124
  )
125
- @customer_address = Parsing::Standard::StringField.new(
125
+ @customer_address = Parsing::Standard::AddressField.new(
126
126
  prediction['customer_address'],
127
127
  page_id
128
128
  )
@@ -182,7 +182,7 @@ module Mindee
182
182
  prediction['reference_numbers'].each do |item|
183
183
  @reference_numbers.push(Parsing::Standard::StringField.new(item, page_id))
184
184
  end
185
- @shipping_address = Parsing::Standard::StringField.new(
185
+ @shipping_address = Parsing::Standard::AddressField.new(
186
186
  prediction['shipping_address'],
187
187
  page_id
188
188
  )
@@ -190,7 +190,7 @@ module Mindee
190
190
  prediction['subcategory'],
191
191
  page_id
192
192
  )
193
- @supplier_address = Parsing::Standard::StringField.new(
193
+ @supplier_address = Parsing::Standard::AddressField.new(
194
194
  prediction['supplier_address'],
195
195
  page_id
196
196
  )
@@ -10,13 +10,13 @@ module Mindee
10
10
  class InvoiceV4Document < Mindee::Parsing::Common::Prediction
11
11
  include Mindee::Parsing::Standard
12
12
  # The customer billing address.
13
- # @return [Mindee::Parsing::Standard::StringField]
13
+ # @return [Mindee::Parsing::Standard::AddressField]
14
14
  attr_reader :billing_address
15
15
  # The purchase category.
16
16
  # @return [Mindee::Parsing::Standard::ClassificationField]
17
17
  attr_reader :category
18
18
  # The address of the customer.
19
- # @return [Mindee::Parsing::Standard::StringField]
19
+ # @return [Mindee::Parsing::Standard::AddressField]
20
20
  attr_reader :customer_address
21
21
  # List of company registration numbers associated to the customer.
22
22
  # @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
@@ -58,13 +58,13 @@ module Mindee
58
58
  # @return [Array<Mindee::Parsing::Standard::StringField>]
59
59
  attr_reader :reference_numbers
60
60
  # Customer's delivery address.
61
- # @return [Mindee::Parsing::Standard::StringField]
61
+ # @return [Mindee::Parsing::Standard::AddressField]
62
62
  attr_reader :shipping_address
63
63
  # The purchase subcategory for transport, food and shopping.
64
64
  # @return [Mindee::Parsing::Standard::ClassificationField]
65
65
  attr_reader :subcategory
66
66
  # The address of the supplier or merchant.
67
- # @return [Mindee::Parsing::Standard::StringField]
67
+ # @return [Mindee::Parsing::Standard::AddressField]
68
68
  attr_reader :supplier_address
69
69
  # List of company registration numbers associated to the supplier.
70
70
  # @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
@@ -101,7 +101,7 @@ module Mindee
101
101
  # @param page_id [Integer, nil]
102
102
  def initialize(prediction, page_id)
103
103
  super
104
- @billing_address = Parsing::Standard::StringField.new(
104
+ @billing_address = Parsing::Standard::AddressField.new(
105
105
  prediction['billing_address'],
106
106
  page_id
107
107
  )
@@ -109,7 +109,7 @@ module Mindee
109
109
  prediction['category'],
110
110
  page_id
111
111
  )
112
- @customer_address = Parsing::Standard::StringField.new(
112
+ @customer_address = Parsing::Standard::AddressField.new(
113
113
  prediction['customer_address'],
114
114
  page_id
115
115
  )
@@ -159,7 +159,7 @@ module Mindee
159
159
  prediction['reference_numbers'].each do |item|
160
160
  @reference_numbers.push(Parsing::Standard::StringField.new(item, page_id))
161
161
  end
162
- @shipping_address = Parsing::Standard::StringField.new(
162
+ @shipping_address = Parsing::Standard::AddressField.new(
163
163
  prediction['shipping_address'],
164
164
  page_id
165
165
  )
@@ -167,7 +167,7 @@ module Mindee
167
167
  prediction['subcategory'],
168
168
  page_id
169
169
  )
170
- @supplier_address = Parsing::Standard::StringField.new(
170
+ @supplier_address = Parsing::Standard::AddressField.new(
171
171
  prediction['supplier_address'],
172
172
  page_id
173
173
  )
@@ -3,7 +3,7 @@
3
3
  # Mindee
4
4
  module Mindee
5
5
  # Current version.
6
- VERSION = '4.5.0'
6
+ VERSION = '4.6.0'
7
7
 
8
8
  # Finds and return the current platform.
9
9
  # @return [Symbol, Hash[Symbol | String, Regexp], Nil?]
data/mindee.gemspec CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'rake', '~> 13.2'
38
38
  spec.add_development_dependency 'rbs', '~> 3.6'
39
39
  spec.add_development_dependency 'rspec', '~> 3.13'
40
- spec.add_development_dependency 'rubocop', '~> 1.75'
40
+ spec.add_development_dependency 'rubocop', '~> 1.76'
41
41
  spec.add_development_dependency 'steep', '~> 1.7'
42
42
  spec.add_development_dependency 'yard', '~> 0.9'
43
43
  end
@@ -0,0 +1,18 @@
1
+ # lib/mindee/parsing/standard/address_field.rb
2
+ module Mindee
3
+ module Parsing
4
+ module Standard
5
+ class AddressField < StringField
6
+ def street_number: -> String
7
+ def street_name: -> String
8
+ def po_box: -> String
9
+ def address_complement: -> String
10
+ def city: -> String
11
+ def postal_code: -> String
12
+ def state: -> String
13
+ def country: -> String
14
+ def initialize: (Hash[Symbol | String, untyped], ?Integer?, ?reconstructed: bool) -> void
15
+ end
16
+ end
17
+ end
18
+ end
@@ -5,9 +5,9 @@ module Mindee
5
5
  module FinancialDocument
6
6
  class FinancialDocumentV1Document < Parsing::Common::Prediction
7
7
  def initialize: (Hash[Symbol | String, untyped], Integer?) -> void
8
- def billing_address: -> (Parsing::Standard::StringField)
8
+ def billing_address: -> (Parsing::Standard::AddressField)
9
9
  def category: -> (Parsing::Standard::ClassificationField)
10
- def customer_address: -> (Parsing::Standard::StringField)
10
+ def customer_address: -> (Parsing::Standard::AddressField)
11
11
  def customer_company_registrations: -> (Array[Parsing::Standard::CompanyRegistrationField])
12
12
  def customer_id: -> (Parsing::Standard::StringField)
13
13
  def customer_name: -> (Parsing::Standard::StringField)
@@ -23,9 +23,9 @@ module Mindee
23
23
  def po_number: -> (Parsing::Standard::StringField)
24
24
  def receipt_number: -> (Parsing::Standard::StringField)
25
25
  def reference_numbers: -> (Array[Parsing::Standard::StringField])
26
- def shipping_address: -> (Parsing::Standard::StringField)
26
+ def shipping_address: -> (Parsing::Standard::AddressField)
27
27
  def subcategory: -> (Parsing::Standard::ClassificationField)
28
- def supplier_address: -> (Parsing::Standard::StringField)
28
+ def supplier_address: -> (Parsing::Standard::AddressField)
29
29
  def supplier_company_registrations: -> (Array[Parsing::Standard::CompanyRegistrationField])
30
30
  def supplier_email: -> (Parsing::Standard::StringField)
31
31
  def supplier_name: -> (Parsing::Standard::StringField)
@@ -5,9 +5,9 @@ module Mindee
5
5
  module Invoice
6
6
  class InvoiceV4Document < Parsing::Common::Prediction
7
7
  def initialize: (Hash[Symbol | String, untyped], Integer?) -> void
8
- def billing_address: -> (Parsing::Standard::StringField)
8
+ def billing_address: -> (Parsing::Standard::AddressField)
9
9
  def category: -> (Parsing::Standard::ClassificationField)
10
- def customer_address: -> (Parsing::Standard::StringField)
10
+ def customer_address: -> (Parsing::Standard::AddressField)
11
11
  def customer_company_registrations: -> (Array[Parsing::Standard::CompanyRegistrationField])
12
12
  def customer_id: -> (Parsing::Standard::StringField)
13
13
  def customer_name: -> (Parsing::Standard::StringField)
@@ -21,9 +21,9 @@ module Mindee
21
21
  def payment_date: -> (Parsing::Standard::DateField)
22
22
  def po_number: -> (Parsing::Standard::StringField)
23
23
  def reference_numbers: -> (Array[Parsing::Standard::StringField])
24
- def shipping_address: -> (Parsing::Standard::StringField)
24
+ def shipping_address: -> (Parsing::Standard::AddressField)
25
25
  def subcategory: -> (Parsing::Standard::ClassificationField)
26
- def supplier_address: -> (Parsing::Standard::StringField)
26
+ def supplier_address: -> (Parsing::Standard::AddressField)
27
27
  def supplier_company_registrations: -> (Array[Parsing::Standard::CompanyRegistrationField])
28
28
  def supplier_email: -> (Parsing::Standard::StringField)
29
29
  def supplier_name: -> (Parsing::Standard::StringField)
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.5.0
4
+ version: 4.6.0
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-05-28 00:00:00.000000000 Z
11
+ date: 2025-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -148,14 +148,14 @@ dependencies:
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: '1.75'
151
+ version: '1.76'
152
152
  type: :development
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: '1.75'
158
+ version: '1.76'
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: steep
161
161
  requirement: !ruby/object:Gem::Requirement
@@ -341,6 +341,7 @@ files:
341
341
  - lib/mindee/parsing/common/workflow_response.rb
342
342
  - lib/mindee/parsing/standard.rb
343
343
  - lib/mindee/parsing/standard/abstract_field.rb
344
+ - lib/mindee/parsing/standard/address_field.rb
344
345
  - lib/mindee/parsing/standard/amount_field.rb
345
346
  - lib/mindee/parsing/standard/base_field.rb
346
347
  - lib/mindee/parsing/standard/boolean_field.rb
@@ -588,6 +589,7 @@ files:
588
589
  - sig/mindee/parsing/common/product.rbs
589
590
  - sig/mindee/parsing/common/workflow_response.rbs
590
591
  - sig/mindee/parsing/standard/abstract_field.rbs
592
+ - sig/mindee/parsing/standard/address_field.rbs
591
593
  - sig/mindee/parsing/standard/amount_field.rbs
592
594
  - sig/mindee/parsing/standard/base_field.rbs
593
595
  - sig/mindee/parsing/standard/boolean_field.rbs