cloudmersive-ocr-api-client 1.4.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -4
  3. data/docs/BusinessCardRecognitionResult.md +8 -8
  4. data/docs/FieldResult.md +2 -2
  5. data/docs/FormDefinitionTemplate.md +2 -1
  6. data/docs/FormFieldDefinition.md +13 -13
  7. data/docs/FormRecognitionResult.md +3 -2
  8. data/docs/FormTableColumnDefinition.md +13 -0
  9. data/docs/FormTableDefinition.md +11 -0
  10. data/docs/ImageOcrApi.md +5 -3
  11. data/docs/ImageToLinesWithLocationResult.md +1 -1
  12. data/docs/ImageToWordsWithLocationResult.md +1 -1
  13. data/docs/OcrPageResultWithLinesWithLocation.md +1 -1
  14. data/docs/OcrPageResultWithWordsWithLocation.md +1 -1
  15. data/docs/OcrPhotoTextElement.md +1 -0
  16. data/docs/PdfToLinesWithLocationResult.md +2 -2
  17. data/docs/PdfToTextResponse.md +2 -2
  18. data/docs/PdfToWordsWithLocationResult.md +2 -2
  19. data/docs/PhotoToWordsWithLocationResult.md +1 -1
  20. data/docs/Point.md +9 -0
  21. data/docs/PreprocessingApi.md +55 -0
  22. data/docs/ReceiptLineItem.md +2 -2
  23. data/docs/ReceiptRecognitionResult.md +8 -8
  24. data/docs/TableCellResult.md +9 -0
  25. data/docs/TableResult.md +9 -0
  26. data/docs/TableRowResult.md +8 -0
  27. data/lib/cloudmersive-ocr-api-client.rb +6 -0
  28. data/lib/cloudmersive-ocr-api-client/api/image_ocr_api.rb +6 -3
  29. data/lib/cloudmersive-ocr-api-client/api/preprocessing_api.rb +56 -0
  30. data/lib/cloudmersive-ocr-api-client/models/business_card_recognition_result.rb +8 -0
  31. data/lib/cloudmersive-ocr-api-client/models/field_result.rb +2 -0
  32. data/lib/cloudmersive-ocr-api-client/models/form_definition_template.rb +17 -4
  33. data/lib/cloudmersive-ocr-api-client/models/form_field_definition.rb +13 -0
  34. data/lib/cloudmersive-ocr-api-client/models/form_recognition_result.rb +18 -4
  35. data/lib/cloudmersive-ocr-api-client/models/form_table_column_definition.rb +239 -0
  36. data/lib/cloudmersive-ocr-api-client/models/form_table_definition.rb +221 -0
  37. data/lib/cloudmersive-ocr-api-client/models/image_to_lines_with_location_result.rb +1 -0
  38. data/lib/cloudmersive-ocr-api-client/models/image_to_words_with_location_result.rb +1 -0
  39. data/lib/cloudmersive-ocr-api-client/models/ocr_page_result_with_lines_with_location.rb +11 -10
  40. data/lib/cloudmersive-ocr-api-client/models/ocr_page_result_with_words_with_location.rb +11 -10
  41. data/lib/cloudmersive-ocr-api-client/models/ocr_photo_text_element.rb +13 -1
  42. data/lib/cloudmersive-ocr-api-client/models/pdf_to_lines_with_location_result.rb +2 -0
  43. data/lib/cloudmersive-ocr-api-client/models/pdf_to_text_response.rb +2 -0
  44. data/lib/cloudmersive-ocr-api-client/models/pdf_to_words_with_location_result.rb +2 -0
  45. data/lib/cloudmersive-ocr-api-client/models/photo_to_words_with_location_result.rb +1 -0
  46. data/lib/cloudmersive-ocr-api-client/models/point.rb +199 -0
  47. data/lib/cloudmersive-ocr-api-client/models/receipt_line_item.rb +2 -0
  48. data/lib/cloudmersive-ocr-api-client/models/receipt_recognition_result.rb +8 -0
  49. data/lib/cloudmersive-ocr-api-client/models/table_cell_result.rb +201 -0
  50. data/lib/cloudmersive-ocr-api-client/models/table_result.rb +201 -0
  51. data/lib/cloudmersive-ocr-api-client/models/table_row_result.rb +191 -0
  52. data/lib/cloudmersive-ocr-api-client/version.rb +1 -1
  53. data/spec/api/image_ocr_api_spec.rb +2 -1
  54. data/spec/api/preprocessing_api_spec.rb +12 -0
  55. data/spec/models/form_definition_template_spec.rb +6 -0
  56. data/spec/models/form_recognition_result_spec.rb +6 -0
  57. data/spec/models/form_table_column_definition_spec.rb +72 -0
  58. data/spec/models/form_table_definition_spec.rb +60 -0
  59. data/spec/models/ocr_page_result_with_lines_with_location_spec.rb +2 -2
  60. data/spec/models/ocr_page_result_with_words_with_location_spec.rb +2 -2
  61. data/spec/models/ocr_photo_text_element_spec.rb +6 -0
  62. data/spec/models/point_spec.rb +48 -0
  63. data/spec/models/table_cell_result_spec.rb +48 -0
  64. data/spec/models/table_result_spec.rb +48 -0
  65. data/spec/models/table_row_result_spec.rb +42 -0
  66. metadata +20 -2
@@ -15,8 +15,10 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # Response from an OCR to words with location operation. Includes the confience rating and converted text result, along with the locations of the words in the pages.
17
17
  class PdfToWordsWithLocationResult
18
+ # True if successful, false otherwise
18
19
  attr_accessor :successful
19
20
 
21
+ # OCR page results
20
22
  attr_accessor :ocr_pages
21
23
 
22
24
 
@@ -15,6 +15,7 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # Result of an photo to words-with-location OCR operation
17
17
  class PhotoToWordsWithLocationResult
18
+ # True if successful, false otherwise
18
19
  attr_accessor :successful
19
20
 
20
21
  # Word elements in the image
@@ -0,0 +1,199 @@
1
+ =begin
2
+ #ocrapi
3
+
4
+ #The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveOcrApiClient
16
+ # Point location in 2D in an image, where 0, 0 represents the top/left corner of the image
17
+ class Point
18
+ # X location in 2D in the image, where 0 represents the left edge of the image
19
+ attr_accessor :x
20
+
21
+ # Y location in 2D in the image, where 0 represents the top edge of the image
22
+ attr_accessor :y
23
+
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'x' => :'X',
29
+ :'y' => :'Y'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'x' => :'Integer',
37
+ :'y' => :'Integer'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
48
+
49
+ if attributes.has_key?(:'X')
50
+ self.x = attributes[:'X']
51
+ end
52
+
53
+ if attributes.has_key?(:'Y')
54
+ self.y = attributes[:'Y']
55
+ end
56
+
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ return invalid_properties
64
+ end
65
+
66
+ # Check to see if the all the properties in the model are valid
67
+ # @return true if the model is valid
68
+ def valid?
69
+ return true
70
+ end
71
+
72
+ # Checks equality by comparing each attribute.
73
+ # @param [Object] Object to be compared
74
+ def ==(o)
75
+ return true if self.equal?(o)
76
+ self.class == o.class &&
77
+ x == o.x &&
78
+ y == o.y
79
+ end
80
+
81
+ # @see the `==` method
82
+ # @param [Object] Object to be compared
83
+ def eql?(o)
84
+ self == o
85
+ end
86
+
87
+ # Calculates hash code according to all attributes.
88
+ # @return [Fixnum] Hash code
89
+ def hash
90
+ [x, y].hash
91
+ end
92
+
93
+ # Builds the object from hash
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ # @return [Object] Returns the model itself
96
+ def build_from_hash(attributes)
97
+ return nil unless attributes.is_a?(Hash)
98
+ self.class.swagger_types.each_pair do |key, type|
99
+ if type =~ /\AArray<(.*)>/i
100
+ # check to ensure the input is an array given that the the attribute
101
+ # is documented as an array but the input is not
102
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
103
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
104
+ end
105
+ elsif !attributes[self.class.attribute_map[key]].nil?
106
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
107
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
108
+ end
109
+
110
+ self
111
+ end
112
+
113
+ # Deserializes the data based on type
114
+ # @param string type Data type
115
+ # @param string value Value to be deserialized
116
+ # @return [Object] Deserialized data
117
+ def _deserialize(type, value)
118
+ case type.to_sym
119
+ when :DateTime
120
+ DateTime.parse(value)
121
+ when :Date
122
+ Date.parse(value)
123
+ when :String
124
+ value.to_s
125
+ when :Integer
126
+ value.to_i
127
+ when :Float
128
+ value.to_f
129
+ when :BOOLEAN
130
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
131
+ true
132
+ else
133
+ false
134
+ end
135
+ when :Object
136
+ # generic object (usually a Hash), return directly
137
+ value
138
+ when /\AArray<(?<inner_type>.+)>\z/
139
+ inner_type = Regexp.last_match[:inner_type]
140
+ value.map { |v| _deserialize(inner_type, v) }
141
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
142
+ k_type = Regexp.last_match[:k_type]
143
+ v_type = Regexp.last_match[:v_type]
144
+ {}.tap do |hash|
145
+ value.each do |k, v|
146
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
147
+ end
148
+ end
149
+ else # model
150
+ temp_model = CloudmersiveOcrApiClient.const_get(type).new
151
+ temp_model.build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ # Returns the string representation of the object
156
+ # @return [String] String presentation of the object
157
+ def to_s
158
+ to_hash.to_s
159
+ end
160
+
161
+ # to_body is an alias to to_hash (backward compatibility)
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_body
164
+ to_hash
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ next if value.nil?
174
+ hash[param] = _to_hash(value)
175
+ end
176
+ hash
177
+ end
178
+
179
+ # Outputs non-array value in the form of hash
180
+ # For object, use to_hash. Otherwise, just return the value
181
+ # @param [Object] value Any valid value
182
+ # @return [Hash] Returns the value in the form of hash
183
+ def _to_hash(value)
184
+ if value.is_a?(Array)
185
+ value.compact.map{ |v| _to_hash(v) }
186
+ elsif value.is_a?(Hash)
187
+ {}.tap do |hash|
188
+ value.each { |k, v| hash[k] = _to_hash(v) }
189
+ end
190
+ elsif value.respond_to? :to_hash
191
+ value.to_hash
192
+ else
193
+ value
194
+ end
195
+ end
196
+
197
+ end
198
+
199
+ end
@@ -15,8 +15,10 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # Receipt line item, comprised of a product or item and a price (if available)
17
17
  class ReceiptLineItem
18
+ # Description of the item
18
19
  attr_accessor :item_description
19
20
 
21
+ # Price of the item if available
20
22
  attr_accessor :item_price
21
23
 
22
24
 
@@ -15,20 +15,28 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # Result of recognizing a receipt, to extract the key information from the receipt
17
17
  class ReceiptRecognitionResult
18
+ # True if the operation was successful, false otherwise
18
19
  attr_accessor :successful
19
20
 
21
+ # The date and time printed on the receipt (if included on the receipt)
20
22
  attr_accessor :timestamp
21
23
 
24
+ # The name of the business printed on the receipt (if included on the receipt)
22
25
  attr_accessor :business_name
23
26
 
27
+ # The website URL of the business printed on the receipt (if included on the receipt)
24
28
  attr_accessor :business_website
25
29
 
30
+ # The address of the business printed on the receipt (if included on the receipt)
26
31
  attr_accessor :address_string
27
32
 
33
+ # The phone number printed on the receipt (if included on the receipt)
28
34
  attr_accessor :phone_number
29
35
 
36
+ # The individual line items comprising the order; does not include total (see ReceiptTotal)
30
37
  attr_accessor :receipt_items
31
38
 
39
+ # The total monetary value of the receipt (if included on the receipt)
32
40
  attr_accessor :receipt_total
33
41
 
34
42
 
@@ -0,0 +1,201 @@
1
+ =begin
2
+ #ocrapi
3
+
4
+ #The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveOcrApiClient
16
+ # The recognition result of one cell in one row in a table of a form
17
+ class TableCellResult
18
+ # The ID of the column
19
+ attr_accessor :column_id
20
+
21
+ # Result cell value(s) extracted
22
+ attr_accessor :cell_values
23
+
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'column_id' => :'ColumnID',
29
+ :'cell_values' => :'CellValues'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'column_id' => :'String',
37
+ :'cell_values' => :'Array<OcrPhotoTextElement>'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
48
+
49
+ if attributes.has_key?(:'ColumnID')
50
+ self.column_id = attributes[:'ColumnID']
51
+ end
52
+
53
+ if attributes.has_key?(:'CellValues')
54
+ if (value = attributes[:'CellValues']).is_a?(Array)
55
+ self.cell_values = value
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properties with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ return invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ return true
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(o)
77
+ return true if self.equal?(o)
78
+ self.class == o.class &&
79
+ column_id == o.column_id &&
80
+ cell_values == o.cell_values
81
+ end
82
+
83
+ # @see the `==` method
84
+ # @param [Object] Object to be compared
85
+ def eql?(o)
86
+ self == o
87
+ end
88
+
89
+ # Calculates hash code according to all attributes.
90
+ # @return [Fixnum] Hash code
91
+ def hash
92
+ [column_id, cell_values].hash
93
+ end
94
+
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def build_from_hash(attributes)
99
+ return nil unless attributes.is_a?(Hash)
100
+ self.class.swagger_types.each_pair do |key, type|
101
+ if type =~ /\AArray<(.*)>/i
102
+ # check to ensure the input is an array given that the the attribute
103
+ # is documented as an array but the input is not
104
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
105
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
106
+ end
107
+ elsif !attributes[self.class.attribute_map[key]].nil?
108
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
109
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
110
+ end
111
+
112
+ self
113
+ end
114
+
115
+ # Deserializes the data based on type
116
+ # @param string type Data type
117
+ # @param string value Value to be deserialized
118
+ # @return [Object] Deserialized data
119
+ def _deserialize(type, value)
120
+ case type.to_sym
121
+ when :DateTime
122
+ DateTime.parse(value)
123
+ when :Date
124
+ Date.parse(value)
125
+ when :String
126
+ value.to_s
127
+ when :Integer
128
+ value.to_i
129
+ when :Float
130
+ value.to_f
131
+ when :BOOLEAN
132
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
133
+ true
134
+ else
135
+ false
136
+ end
137
+ when :Object
138
+ # generic object (usually a Hash), return directly
139
+ value
140
+ when /\AArray<(?<inner_type>.+)>\z/
141
+ inner_type = Regexp.last_match[:inner_type]
142
+ value.map { |v| _deserialize(inner_type, v) }
143
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
144
+ k_type = Regexp.last_match[:k_type]
145
+ v_type = Regexp.last_match[:v_type]
146
+ {}.tap do |hash|
147
+ value.each do |k, v|
148
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
149
+ end
150
+ end
151
+ else # model
152
+ temp_model = CloudmersiveOcrApiClient.const_get(type).new
153
+ temp_model.build_from_hash(value)
154
+ end
155
+ end
156
+
157
+ # Returns the string representation of the object
158
+ # @return [String] String presentation of the object
159
+ def to_s
160
+ to_hash.to_s
161
+ end
162
+
163
+ # to_body is an alias to to_hash (backward compatibility)
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_body
166
+ to_hash
167
+ end
168
+
169
+ # Returns the object in the form of hash
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_hash
172
+ hash = {}
173
+ self.class.attribute_map.each_pair do |attr, param|
174
+ value = self.send(attr)
175
+ next if value.nil?
176
+ hash[param] = _to_hash(value)
177
+ end
178
+ hash
179
+ end
180
+
181
+ # Outputs non-array value in the form of hash
182
+ # For object, use to_hash. Otherwise, just return the value
183
+ # @param [Object] value Any valid value
184
+ # @return [Hash] Returns the value in the form of hash
185
+ def _to_hash(value)
186
+ if value.is_a?(Array)
187
+ value.compact.map{ |v| _to_hash(v) }
188
+ elsif value.is_a?(Hash)
189
+ {}.tap do |hash|
190
+ value.each { |k, v| hash[k] = _to_hash(v) }
191
+ end
192
+ elsif value.respond_to? :to_hash
193
+ value.to_hash
194
+ else
195
+ value
196
+ end
197
+ end
198
+
199
+ end
200
+
201
+ end