cloudmersive-ocr-api-client 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -0
- data/README.md +150 -0
- data/Rakefile +8 -0
- data/cloudmersive-ocr-api-client.gemspec +45 -0
- data/docs/BusinessCardRecognitionResult.md +15 -0
- data/docs/FieldResult.md +9 -0
- data/docs/FormDefinitionTemplate.md +9 -0
- data/docs/FormFieldDefinition.md +25 -0
- data/docs/FormRecognitionResult.md +12 -0
- data/docs/FormTableColumnDefinition.md +13 -0
- data/docs/FormTableDefinition.md +11 -0
- data/docs/GetPageAngleResult.md +9 -0
- data/docs/ImageOcrApi.md +571 -0
- data/docs/ImageToLinesWithLocationResult.md +9 -0
- data/docs/ImageToTextResponse.md +9 -0
- data/docs/ImageToWordsWithLocationResult.md +9 -0
- data/docs/OcrLineElement.md +9 -0
- data/docs/OcrPageResult.md +10 -0
- data/docs/OcrPageResultWithLinesWithLocation.md +10 -0
- data/docs/OcrPageResultWithWordsWithLocation.md +10 -0
- data/docs/OcrPhotoTextElement.md +14 -0
- data/docs/OcrWordElement.md +18 -0
- data/docs/PdfOcrApi.md +191 -0
- data/docs/PdfToLinesWithLocationResult.md +9 -0
- data/docs/PdfToTextResponse.md +9 -0
- data/docs/PdfToWordsWithLocationResult.md +9 -0
- data/docs/PhotoToWordsWithLocationResult.md +10 -0
- data/docs/Point.md +9 -0
- data/docs/PreprocessingApi.md +338 -0
- data/docs/ReceiptLineItem.md +9 -0
- data/docs/ReceiptRecognitionResult.md +16 -0
- data/docs/ReceiptsApi.md +63 -0
- data/docs/TableCellResult.md +9 -0
- data/docs/TableResult.md +9 -0
- data/docs/TableRowResult.md +8 -0
- data/git_push.sh +55 -0
- data/lib/cloudmersive-ocr-api-client.rb +70 -0
- data/lib/cloudmersive-ocr-api-client/api/image_ocr_api.rb +596 -0
- data/lib/cloudmersive-ocr-api-client/api/pdf_ocr_api.rb +207 -0
- data/lib/cloudmersive-ocr-api-client/api/preprocessing_api.rb +353 -0
- data/lib/cloudmersive-ocr-api-client/api/receipts_api.rb +78 -0
- data/lib/cloudmersive-ocr-api-client/api_client.rb +391 -0
- data/lib/cloudmersive-ocr-api-client/api_error.rb +38 -0
- data/lib/cloudmersive-ocr-api-client/configuration.rb +209 -0
- data/lib/cloudmersive-ocr-api-client/models/business_card_recognition_result.rb +256 -0
- data/lib/cloudmersive-ocr-api-client/models/field_result.rb +198 -0
- data/lib/cloudmersive-ocr-api-client/models/form_definition_template.rb +200 -0
- data/lib/cloudmersive-ocr-api-client/models/form_field_definition.rb +358 -0
- data/lib/cloudmersive-ocr-api-client/models/form_recognition_result.rb +232 -0
- data/lib/cloudmersive-ocr-api-client/models/form_table_column_definition.rb +236 -0
- data/lib/cloudmersive-ocr-api-client/models/form_table_definition.rb +218 -0
- data/lib/cloudmersive-ocr-api-client/models/get_page_angle_result.rb +196 -0
- data/lib/cloudmersive-ocr-api-client/models/image_to_lines_with_location_result.rb +198 -0
- data/lib/cloudmersive-ocr-api-client/models/image_to_text_response.rb +196 -0
- data/lib/cloudmersive-ocr-api-client/models/image_to_words_with_location_result.rb +198 -0
- data/lib/cloudmersive-ocr-api-client/models/ocr_line_element.rb +198 -0
- data/lib/cloudmersive-ocr-api-client/models/ocr_page_result.rb +205 -0
- data/lib/cloudmersive-ocr-api-client/models/ocr_page_result_with_lines_with_location.rb +208 -0
- data/lib/cloudmersive-ocr-api-client/models/ocr_page_result_with_words_with_location.rb +208 -0
- data/lib/cloudmersive-ocr-api-client/models/ocr_photo_text_element.rb +248 -0
- data/lib/cloudmersive-ocr-api-client/models/ocr_word_element.rb +286 -0
- data/lib/cloudmersive-ocr-api-client/models/pdf_to_lines_with_location_result.rb +198 -0
- data/lib/cloudmersive-ocr-api-client/models/pdf_to_text_response.rb +198 -0
- data/lib/cloudmersive-ocr-api-client/models/pdf_to_words_with_location_result.rb +198 -0
- data/lib/cloudmersive-ocr-api-client/models/photo_to_words_with_location_result.rb +223 -0
- data/lib/cloudmersive-ocr-api-client/models/point.rb +196 -0
- data/lib/cloudmersive-ocr-api-client/models/receipt_line_item.rb +196 -0
- data/lib/cloudmersive-ocr-api-client/models/receipt_recognition_result.rb +268 -0
- data/lib/cloudmersive-ocr-api-client/models/table_cell_result.rb +198 -0
- data/lib/cloudmersive-ocr-api-client/models/table_result.rb +198 -0
- data/lib/cloudmersive-ocr-api-client/models/table_row_result.rb +188 -0
- data/lib/cloudmersive-ocr-api-client/version.rb +15 -0
- data/spec/api/image_ocr_api_spec.rb +169 -0
- data/spec/api/pdf_ocr_api_spec.rb +77 -0
- data/spec/api/preprocessing_api_spec.rb +107 -0
- data/spec/api/receipts_api_spec.rb +47 -0
- data/spec/api_client_spec.rb +243 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/business_card_recognition_result_spec.rb +83 -0
- data/spec/models/field_result_spec.rb +47 -0
- data/spec/models/form_definition_template_spec.rb +47 -0
- data/spec/models/form_field_definition_spec.rb +143 -0
- data/spec/models/form_recognition_result_spec.rb +65 -0
- data/spec/models/form_table_column_definition_spec.rb +71 -0
- data/spec/models/form_table_definition_spec.rb +59 -0
- data/spec/models/get_page_angle_result_spec.rb +47 -0
- data/spec/models/image_to_lines_with_location_result_spec.rb +47 -0
- data/spec/models/image_to_text_response_spec.rb +47 -0
- data/spec/models/image_to_words_with_location_result_spec.rb +47 -0
- data/spec/models/ocr_line_element_spec.rb +47 -0
- data/spec/models/ocr_page_result_spec.rb +53 -0
- data/spec/models/ocr_page_result_with_lines_with_location_spec.rb +53 -0
- data/spec/models/ocr_page_result_with_words_with_location_spec.rb +53 -0
- data/spec/models/ocr_photo_text_element_spec.rb +77 -0
- data/spec/models/ocr_word_element_spec.rb +101 -0
- data/spec/models/pdf_to_lines_with_location_result_spec.rb +47 -0
- data/spec/models/pdf_to_text_response_spec.rb +47 -0
- data/spec/models/pdf_to_words_with_location_result_spec.rb +47 -0
- data/spec/models/photo_to_words_with_location_result_spec.rb +53 -0
- data/spec/models/point_spec.rb +47 -0
- data/spec/models/receipt_line_item_spec.rb +47 -0
- data/spec/models/receipt_recognition_result_spec.rb +89 -0
- data/spec/models/table_cell_result_spec.rb +47 -0
- data/spec/models/table_result_spec.rb +47 -0
- data/spec/models/table_row_result_spec.rb +41 -0
- data/spec/spec_helper.rb +111 -0
- metadata +109 -3
@@ -0,0 +1,248 @@
|
|
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: 2.4.14
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CloudmersiveOcrApiClient
|
16
|
+
# A single text in an OCR document
|
17
|
+
class OcrPhotoTextElement
|
18
|
+
# Text of the word
|
19
|
+
attr_accessor :text
|
20
|
+
|
21
|
+
# X location of the left edge of the word in pixels
|
22
|
+
attr_accessor :x_left
|
23
|
+
|
24
|
+
# Y location of the top edge of the word in pixels
|
25
|
+
attr_accessor :y_top
|
26
|
+
|
27
|
+
# Width of the word in pixels
|
28
|
+
attr_accessor :width
|
29
|
+
|
30
|
+
# Height of the word in pixels
|
31
|
+
attr_accessor :height
|
32
|
+
|
33
|
+
# Points that form the bounding polygon around the text
|
34
|
+
attr_accessor :bounding_points
|
35
|
+
|
36
|
+
# Confidence level of the machine learning result; possible values are 0.0 (lowest accuracy) - 1.0 (highest accuracy)
|
37
|
+
attr_accessor :confidence_level
|
38
|
+
|
39
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
40
|
+
def self.attribute_map
|
41
|
+
{
|
42
|
+
:'text' => :'Text',
|
43
|
+
:'x_left' => :'XLeft',
|
44
|
+
:'y_top' => :'YTop',
|
45
|
+
:'width' => :'Width',
|
46
|
+
:'height' => :'Height',
|
47
|
+
:'bounding_points' => :'BoundingPoints',
|
48
|
+
:'confidence_level' => :'ConfidenceLevel'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Attribute type mapping.
|
53
|
+
def self.swagger_types
|
54
|
+
{
|
55
|
+
:'text' => :'String',
|
56
|
+
:'x_left' => :'Integer',
|
57
|
+
:'y_top' => :'Integer',
|
58
|
+
:'width' => :'Integer',
|
59
|
+
:'height' => :'Integer',
|
60
|
+
:'bounding_points' => :'Array<Point>',
|
61
|
+
:'confidence_level' => :'Float'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# Initializes the object
|
66
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
67
|
+
def initialize(attributes = {})
|
68
|
+
return unless attributes.is_a?(Hash)
|
69
|
+
|
70
|
+
# convert string to symbol for hash key
|
71
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
72
|
+
|
73
|
+
if attributes.has_key?(:'Text')
|
74
|
+
self.text = attributes[:'Text']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.has_key?(:'XLeft')
|
78
|
+
self.x_left = attributes[:'XLeft']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.has_key?(:'YTop')
|
82
|
+
self.y_top = attributes[:'YTop']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.has_key?(:'Width')
|
86
|
+
self.width = attributes[:'Width']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.has_key?(:'Height')
|
90
|
+
self.height = attributes[:'Height']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.has_key?(:'BoundingPoints')
|
94
|
+
if (value = attributes[:'BoundingPoints']).is_a?(Array)
|
95
|
+
self.bounding_points = value
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.has_key?(:'ConfidenceLevel')
|
100
|
+
self.confidence_level = attributes[:'ConfidenceLevel']
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
105
|
+
# @return Array for valid properties with the reasons
|
106
|
+
def list_invalid_properties
|
107
|
+
invalid_properties = Array.new
|
108
|
+
invalid_properties
|
109
|
+
end
|
110
|
+
|
111
|
+
# Check to see if the all the properties in the model are valid
|
112
|
+
# @return true if the model is valid
|
113
|
+
def valid?
|
114
|
+
true
|
115
|
+
end
|
116
|
+
|
117
|
+
# Checks equality by comparing each attribute.
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def ==(o)
|
120
|
+
return true if self.equal?(o)
|
121
|
+
self.class == o.class &&
|
122
|
+
text == o.text &&
|
123
|
+
x_left == o.x_left &&
|
124
|
+
y_top == o.y_top &&
|
125
|
+
width == o.width &&
|
126
|
+
height == o.height &&
|
127
|
+
bounding_points == o.bounding_points &&
|
128
|
+
confidence_level == o.confidence_level
|
129
|
+
end
|
130
|
+
|
131
|
+
# @see the `==` method
|
132
|
+
# @param [Object] Object to be compared
|
133
|
+
def eql?(o)
|
134
|
+
self == o
|
135
|
+
end
|
136
|
+
|
137
|
+
# Calculates hash code according to all attributes.
|
138
|
+
# @return [Fixnum] Hash code
|
139
|
+
def hash
|
140
|
+
[text, x_left, y_top, width, height, bounding_points, confidence_level].hash
|
141
|
+
end
|
142
|
+
|
143
|
+
# Builds the object from hash
|
144
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
145
|
+
# @return [Object] Returns the model itself
|
146
|
+
def build_from_hash(attributes)
|
147
|
+
return nil unless attributes.is_a?(Hash)
|
148
|
+
self.class.swagger_types.each_pair do |key, type|
|
149
|
+
if type =~ /\AArray<(.*)>/i
|
150
|
+
# check to ensure the input is an array given that the attribute
|
151
|
+
# is documented as an array but the input is not
|
152
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
153
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
154
|
+
end
|
155
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
156
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
157
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
158
|
+
end
|
159
|
+
|
160
|
+
self
|
161
|
+
end
|
162
|
+
|
163
|
+
# Deserializes the data based on type
|
164
|
+
# @param string type Data type
|
165
|
+
# @param string value Value to be deserialized
|
166
|
+
# @return [Object] Deserialized data
|
167
|
+
def _deserialize(type, value)
|
168
|
+
case type.to_sym
|
169
|
+
when :DateTime
|
170
|
+
DateTime.parse(value)
|
171
|
+
when :Date
|
172
|
+
Date.parse(value)
|
173
|
+
when :String
|
174
|
+
value.to_s
|
175
|
+
when :Integer
|
176
|
+
value.to_i
|
177
|
+
when :Float
|
178
|
+
value.to_f
|
179
|
+
when :BOOLEAN
|
180
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
181
|
+
true
|
182
|
+
else
|
183
|
+
false
|
184
|
+
end
|
185
|
+
when :Object
|
186
|
+
# generic object (usually a Hash), return directly
|
187
|
+
value
|
188
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
189
|
+
inner_type = Regexp.last_match[:inner_type]
|
190
|
+
value.map { |v| _deserialize(inner_type, v) }
|
191
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
192
|
+
k_type = Regexp.last_match[:k_type]
|
193
|
+
v_type = Regexp.last_match[:v_type]
|
194
|
+
{}.tap do |hash|
|
195
|
+
value.each do |k, v|
|
196
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
else # model
|
200
|
+
temp_model = CloudmersiveOcrApiClient.const_get(type).new
|
201
|
+
temp_model.build_from_hash(value)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
# Returns the string representation of the object
|
206
|
+
# @return [String] String presentation of the object
|
207
|
+
def to_s
|
208
|
+
to_hash.to_s
|
209
|
+
end
|
210
|
+
|
211
|
+
# to_body is an alias to to_hash (backward compatibility)
|
212
|
+
# @return [Hash] Returns the object in the form of hash
|
213
|
+
def to_body
|
214
|
+
to_hash
|
215
|
+
end
|
216
|
+
|
217
|
+
# Returns the object in the form of hash
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
219
|
+
def to_hash
|
220
|
+
hash = {}
|
221
|
+
self.class.attribute_map.each_pair do |attr, param|
|
222
|
+
value = self.send(attr)
|
223
|
+
next if value.nil?
|
224
|
+
hash[param] = _to_hash(value)
|
225
|
+
end
|
226
|
+
hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Outputs non-array value in the form of hash
|
230
|
+
# For object, use to_hash. Otherwise, just return the value
|
231
|
+
# @param [Object] value Any valid value
|
232
|
+
# @return [Hash] Returns the value in the form of hash
|
233
|
+
def _to_hash(value)
|
234
|
+
if value.is_a?(Array)
|
235
|
+
value.compact.map { |v| _to_hash(v) }
|
236
|
+
elsif value.is_a?(Hash)
|
237
|
+
{}.tap do |hash|
|
238
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
239
|
+
end
|
240
|
+
elsif value.respond_to? :to_hash
|
241
|
+
value.to_hash
|
242
|
+
else
|
243
|
+
value
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
end
|
@@ -0,0 +1,286 @@
|
|
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: 2.4.14
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CloudmersiveOcrApiClient
|
16
|
+
# A single word in an OCR document
|
17
|
+
class OcrWordElement
|
18
|
+
# Text of the word
|
19
|
+
attr_accessor :word_text
|
20
|
+
|
21
|
+
# Line number of the word
|
22
|
+
attr_accessor :line_number
|
23
|
+
|
24
|
+
# Index of the word in the line
|
25
|
+
attr_accessor :word_number
|
26
|
+
|
27
|
+
# X location of the left edge of the word in pixels
|
28
|
+
attr_accessor :x_left
|
29
|
+
|
30
|
+
# Y location of the top edge of the word in pixels
|
31
|
+
attr_accessor :y_top
|
32
|
+
|
33
|
+
# Width of the word in pixels
|
34
|
+
attr_accessor :width
|
35
|
+
|
36
|
+
# Height of the word in pixels
|
37
|
+
attr_accessor :height
|
38
|
+
|
39
|
+
# Confidence level of the machine learning result; possible values are 0.0 (lowest accuracy) - 1.0 (highest accuracy)
|
40
|
+
attr_accessor :confidence_level
|
41
|
+
|
42
|
+
# Index of the containing block
|
43
|
+
attr_accessor :block_number
|
44
|
+
|
45
|
+
# Index of the containing paragraph
|
46
|
+
attr_accessor :paragraph_number
|
47
|
+
|
48
|
+
# Index of the containing page
|
49
|
+
attr_accessor :page_number
|
50
|
+
|
51
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
52
|
+
def self.attribute_map
|
53
|
+
{
|
54
|
+
:'word_text' => :'WordText',
|
55
|
+
:'line_number' => :'LineNumber',
|
56
|
+
:'word_number' => :'WordNumber',
|
57
|
+
:'x_left' => :'XLeft',
|
58
|
+
:'y_top' => :'YTop',
|
59
|
+
:'width' => :'Width',
|
60
|
+
:'height' => :'Height',
|
61
|
+
:'confidence_level' => :'ConfidenceLevel',
|
62
|
+
:'block_number' => :'BlockNumber',
|
63
|
+
:'paragraph_number' => :'ParagraphNumber',
|
64
|
+
:'page_number' => :'PageNumber'
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
# Attribute type mapping.
|
69
|
+
def self.swagger_types
|
70
|
+
{
|
71
|
+
:'word_text' => :'String',
|
72
|
+
:'line_number' => :'Integer',
|
73
|
+
:'word_number' => :'Integer',
|
74
|
+
:'x_left' => :'Integer',
|
75
|
+
:'y_top' => :'Integer',
|
76
|
+
:'width' => :'Integer',
|
77
|
+
:'height' => :'Integer',
|
78
|
+
:'confidence_level' => :'Float',
|
79
|
+
:'block_number' => :'Integer',
|
80
|
+
:'paragraph_number' => :'Integer',
|
81
|
+
:'page_number' => :'Integer'
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
# Initializes the object
|
86
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
87
|
+
def initialize(attributes = {})
|
88
|
+
return unless attributes.is_a?(Hash)
|
89
|
+
|
90
|
+
# convert string to symbol for hash key
|
91
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
92
|
+
|
93
|
+
if attributes.has_key?(:'WordText')
|
94
|
+
self.word_text = attributes[:'WordText']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.has_key?(:'LineNumber')
|
98
|
+
self.line_number = attributes[:'LineNumber']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.has_key?(:'WordNumber')
|
102
|
+
self.word_number = attributes[:'WordNumber']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.has_key?(:'XLeft')
|
106
|
+
self.x_left = attributes[:'XLeft']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.has_key?(:'YTop')
|
110
|
+
self.y_top = attributes[:'YTop']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.has_key?(:'Width')
|
114
|
+
self.width = attributes[:'Width']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.has_key?(:'Height')
|
118
|
+
self.height = attributes[:'Height']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.has_key?(:'ConfidenceLevel')
|
122
|
+
self.confidence_level = attributes[:'ConfidenceLevel']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.has_key?(:'BlockNumber')
|
126
|
+
self.block_number = attributes[:'BlockNumber']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.has_key?(:'ParagraphNumber')
|
130
|
+
self.paragraph_number = attributes[:'ParagraphNumber']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.has_key?(:'PageNumber')
|
134
|
+
self.page_number = attributes[:'PageNumber']
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
139
|
+
# @return Array for valid properties with the reasons
|
140
|
+
def list_invalid_properties
|
141
|
+
invalid_properties = Array.new
|
142
|
+
invalid_properties
|
143
|
+
end
|
144
|
+
|
145
|
+
# Check to see if the all the properties in the model are valid
|
146
|
+
# @return true if the model is valid
|
147
|
+
def valid?
|
148
|
+
true
|
149
|
+
end
|
150
|
+
|
151
|
+
# Checks equality by comparing each attribute.
|
152
|
+
# @param [Object] Object to be compared
|
153
|
+
def ==(o)
|
154
|
+
return true if self.equal?(o)
|
155
|
+
self.class == o.class &&
|
156
|
+
word_text == o.word_text &&
|
157
|
+
line_number == o.line_number &&
|
158
|
+
word_number == o.word_number &&
|
159
|
+
x_left == o.x_left &&
|
160
|
+
y_top == o.y_top &&
|
161
|
+
width == o.width &&
|
162
|
+
height == o.height &&
|
163
|
+
confidence_level == o.confidence_level &&
|
164
|
+
block_number == o.block_number &&
|
165
|
+
paragraph_number == o.paragraph_number &&
|
166
|
+
page_number == o.page_number
|
167
|
+
end
|
168
|
+
|
169
|
+
# @see the `==` method
|
170
|
+
# @param [Object] Object to be compared
|
171
|
+
def eql?(o)
|
172
|
+
self == o
|
173
|
+
end
|
174
|
+
|
175
|
+
# Calculates hash code according to all attributes.
|
176
|
+
# @return [Fixnum] Hash code
|
177
|
+
def hash
|
178
|
+
[word_text, line_number, word_number, x_left, y_top, width, height, confidence_level, block_number, paragraph_number, page_number].hash
|
179
|
+
end
|
180
|
+
|
181
|
+
# Builds the object from hash
|
182
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
183
|
+
# @return [Object] Returns the model itself
|
184
|
+
def build_from_hash(attributes)
|
185
|
+
return nil unless attributes.is_a?(Hash)
|
186
|
+
self.class.swagger_types.each_pair do |key, type|
|
187
|
+
if type =~ /\AArray<(.*)>/i
|
188
|
+
# check to ensure the input is an array given that the attribute
|
189
|
+
# is documented as an array but the input is not
|
190
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
191
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
192
|
+
end
|
193
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
194
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
195
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
196
|
+
end
|
197
|
+
|
198
|
+
self
|
199
|
+
end
|
200
|
+
|
201
|
+
# Deserializes the data based on type
|
202
|
+
# @param string type Data type
|
203
|
+
# @param string value Value to be deserialized
|
204
|
+
# @return [Object] Deserialized data
|
205
|
+
def _deserialize(type, value)
|
206
|
+
case type.to_sym
|
207
|
+
when :DateTime
|
208
|
+
DateTime.parse(value)
|
209
|
+
when :Date
|
210
|
+
Date.parse(value)
|
211
|
+
when :String
|
212
|
+
value.to_s
|
213
|
+
when :Integer
|
214
|
+
value.to_i
|
215
|
+
when :Float
|
216
|
+
value.to_f
|
217
|
+
when :BOOLEAN
|
218
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
219
|
+
true
|
220
|
+
else
|
221
|
+
false
|
222
|
+
end
|
223
|
+
when :Object
|
224
|
+
# generic object (usually a Hash), return directly
|
225
|
+
value
|
226
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
227
|
+
inner_type = Regexp.last_match[:inner_type]
|
228
|
+
value.map { |v| _deserialize(inner_type, v) }
|
229
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
230
|
+
k_type = Regexp.last_match[:k_type]
|
231
|
+
v_type = Regexp.last_match[:v_type]
|
232
|
+
{}.tap do |hash|
|
233
|
+
value.each do |k, v|
|
234
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
else # model
|
238
|
+
temp_model = CloudmersiveOcrApiClient.const_get(type).new
|
239
|
+
temp_model.build_from_hash(value)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
# Returns the string representation of the object
|
244
|
+
# @return [String] String presentation of the object
|
245
|
+
def to_s
|
246
|
+
to_hash.to_s
|
247
|
+
end
|
248
|
+
|
249
|
+
# to_body is an alias to to_hash (backward compatibility)
|
250
|
+
# @return [Hash] Returns the object in the form of hash
|
251
|
+
def to_body
|
252
|
+
to_hash
|
253
|
+
end
|
254
|
+
|
255
|
+
# Returns the object in the form of hash
|
256
|
+
# @return [Hash] Returns the object in the form of hash
|
257
|
+
def to_hash
|
258
|
+
hash = {}
|
259
|
+
self.class.attribute_map.each_pair do |attr, param|
|
260
|
+
value = self.send(attr)
|
261
|
+
next if value.nil?
|
262
|
+
hash[param] = _to_hash(value)
|
263
|
+
end
|
264
|
+
hash
|
265
|
+
end
|
266
|
+
|
267
|
+
# Outputs non-array value in the form of hash
|
268
|
+
# For object, use to_hash. Otherwise, just return the value
|
269
|
+
# @param [Object] value Any valid value
|
270
|
+
# @return [Hash] Returns the value in the form of hash
|
271
|
+
def _to_hash(value)
|
272
|
+
if value.is_a?(Array)
|
273
|
+
value.compact.map { |v| _to_hash(v) }
|
274
|
+
elsif value.is_a?(Hash)
|
275
|
+
{}.tap do |hash|
|
276
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
277
|
+
end
|
278
|
+
elsif value.respond_to? :to_hash
|
279
|
+
value.to_hash
|
280
|
+
else
|
281
|
+
value
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
286
|
+
end
|