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
@@ -0,0 +1,221 @@
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
+ # Definition of a form table for OCR data extraction from images
17
+ class FormTableDefinition
18
+ # Optional; the ID of the table
19
+ attr_accessor :table_id
20
+
21
+ # Definition of the columns in the table
22
+ attr_accessor :column_definitions
23
+
24
+ # Optional - scale factor for target table height - relative to maximum height of headers of columns
25
+ attr_accessor :target_table_height_relative
26
+
27
+ # Optional - scale factor for target row height - relative to height of column header
28
+ attr_accessor :target_row_height_relative
29
+
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'table_id' => :'TableID',
35
+ :'column_definitions' => :'ColumnDefinitions',
36
+ :'target_table_height_relative' => :'TargetTableHeight_Relative',
37
+ :'target_row_height_relative' => :'TargetRowHeight_Relative'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.swagger_types
43
+ {
44
+ :'table_id' => :'String',
45
+ :'column_definitions' => :'Array<FormTableColumnDefinition>',
46
+ :'target_table_height_relative' => :'Float',
47
+ :'target_row_height_relative' => :'Float'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ return unless attributes.is_a?(Hash)
55
+
56
+ # convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
58
+
59
+ if attributes.has_key?(:'TableID')
60
+ self.table_id = attributes[:'TableID']
61
+ end
62
+
63
+ if attributes.has_key?(:'ColumnDefinitions')
64
+ if (value = attributes[:'ColumnDefinitions']).is_a?(Array)
65
+ self.column_definitions = value
66
+ end
67
+ end
68
+
69
+ if attributes.has_key?(:'TargetTableHeight_Relative')
70
+ self.target_table_height_relative = attributes[:'TargetTableHeight_Relative']
71
+ end
72
+
73
+ if attributes.has_key?(:'TargetRowHeight_Relative')
74
+ self.target_row_height_relative = attributes[:'TargetRowHeight_Relative']
75
+ end
76
+
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ return invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ return true
90
+ end
91
+
92
+ # Checks equality by comparing each attribute.
93
+ # @param [Object] Object to be compared
94
+ def ==(o)
95
+ return true if self.equal?(o)
96
+ self.class == o.class &&
97
+ table_id == o.table_id &&
98
+ column_definitions == o.column_definitions &&
99
+ target_table_height_relative == o.target_table_height_relative &&
100
+ target_row_height_relative == o.target_row_height_relative
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Fixnum] Hash code
111
+ def hash
112
+ [table_id, column_definitions, target_table_height_relative, target_row_height_relative].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ self.class.swagger_types.each_pair do |key, type|
121
+ if type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
125
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
126
+ end
127
+ elsif !attributes[self.class.attribute_map[key]].nil?
128
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
129
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
130
+ end
131
+
132
+ self
133
+ end
134
+
135
+ # Deserializes the data based on type
136
+ # @param string type Data type
137
+ # @param string value Value to be deserialized
138
+ # @return [Object] Deserialized data
139
+ def _deserialize(type, value)
140
+ case type.to_sym
141
+ when :DateTime
142
+ DateTime.parse(value)
143
+ when :Date
144
+ Date.parse(value)
145
+ when :String
146
+ value.to_s
147
+ when :Integer
148
+ value.to_i
149
+ when :Float
150
+ value.to_f
151
+ when :BOOLEAN
152
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
153
+ true
154
+ else
155
+ false
156
+ end
157
+ when :Object
158
+ # generic object (usually a Hash), return directly
159
+ value
160
+ when /\AArray<(?<inner_type>.+)>\z/
161
+ inner_type = Regexp.last_match[:inner_type]
162
+ value.map { |v| _deserialize(inner_type, v) }
163
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
164
+ k_type = Regexp.last_match[:k_type]
165
+ v_type = Regexp.last_match[:v_type]
166
+ {}.tap do |hash|
167
+ value.each do |k, v|
168
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
169
+ end
170
+ end
171
+ else # model
172
+ temp_model = CloudmersiveOcrApiClient.const_get(type).new
173
+ temp_model.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ next if value.nil?
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map{ |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end
@@ -15,6 +15,7 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # Result of an image to lines-with-location OCR operation
17
17
  class ImageToLinesWithLocationResult
18
+ # True if successful, false otherwise
18
19
  attr_accessor :successful
19
20
 
20
21
  # Words in the image
@@ -15,6 +15,7 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # Result of an image to words-with-location OCR operation
17
17
  class ImageToWordsWithLocationResult
18
+ # True if successful, false otherwise
18
19
  attr_accessor :successful
19
20
 
20
21
  # Word elements in the image
@@ -15,11 +15,12 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # OCR results of a page, including lines of text and their location
17
17
  class OcrPageResultWithLinesWithLocation
18
- attr_accessor :successful
19
-
20
18
  # Page number of the page that was OCR-ed, starting with 1 for the first page in the PDF file
21
19
  attr_accessor :page_number
22
20
 
21
+ # True if successful, false otherwise
22
+ attr_accessor :successful
23
+
23
24
  # Word elements in the image
24
25
  attr_accessor :lines
25
26
 
@@ -27,8 +28,8 @@ module CloudmersiveOcrApiClient
27
28
  # Attribute mapping from ruby-style variable name to JSON key.
28
29
  def self.attribute_map
29
30
  {
30
- :'successful' => :'Successful',
31
31
  :'page_number' => :'PageNumber',
32
+ :'successful' => :'Successful',
32
33
  :'lines' => :'Lines'
33
34
  }
34
35
  end
@@ -36,8 +37,8 @@ module CloudmersiveOcrApiClient
36
37
  # Attribute type mapping.
37
38
  def self.swagger_types
38
39
  {
39
- :'successful' => :'BOOLEAN',
40
40
  :'page_number' => :'Integer',
41
+ :'successful' => :'BOOLEAN',
41
42
  :'lines' => :'Array<OcrLineElement>'
42
43
  }
43
44
  end
@@ -50,14 +51,14 @@ module CloudmersiveOcrApiClient
50
51
  # convert string to symbol for hash key
51
52
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
52
53
 
53
- if attributes.has_key?(:'Successful')
54
- self.successful = attributes[:'Successful']
55
- end
56
-
57
54
  if attributes.has_key?(:'PageNumber')
58
55
  self.page_number = attributes[:'PageNumber']
59
56
  end
60
57
 
58
+ if attributes.has_key?(:'Successful')
59
+ self.successful = attributes[:'Successful']
60
+ end
61
+
61
62
  if attributes.has_key?(:'Lines')
62
63
  if (value = attributes[:'Lines']).is_a?(Array)
63
64
  self.lines = value
@@ -84,8 +85,8 @@ module CloudmersiveOcrApiClient
84
85
  def ==(o)
85
86
  return true if self.equal?(o)
86
87
  self.class == o.class &&
87
- successful == o.successful &&
88
88
  page_number == o.page_number &&
89
+ successful == o.successful &&
89
90
  lines == o.lines
90
91
  end
91
92
 
@@ -98,7 +99,7 @@ module CloudmersiveOcrApiClient
98
99
  # Calculates hash code according to all attributes.
99
100
  # @return [Fixnum] Hash code
100
101
  def hash
101
- [successful, page_number, lines].hash
102
+ [page_number, successful, lines].hash
102
103
  end
103
104
 
104
105
  # Builds the object from hash
@@ -15,11 +15,12 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # OCR results of a page, including words of text and their location
17
17
  class OcrPageResultWithWordsWithLocation
18
- attr_accessor :successful
19
-
20
18
  # Page number of the page that was OCR-ed, starting with 1 for the first page in the PDF file
21
19
  attr_accessor :page_number
22
20
 
21
+ # True if successful, false otherwise
22
+ attr_accessor :successful
23
+
23
24
  # Word elements in the image
24
25
  attr_accessor :words
25
26
 
@@ -27,8 +28,8 @@ module CloudmersiveOcrApiClient
27
28
  # Attribute mapping from ruby-style variable name to JSON key.
28
29
  def self.attribute_map
29
30
  {
30
- :'successful' => :'Successful',
31
31
  :'page_number' => :'PageNumber',
32
+ :'successful' => :'Successful',
32
33
  :'words' => :'Words'
33
34
  }
34
35
  end
@@ -36,8 +37,8 @@ module CloudmersiveOcrApiClient
36
37
  # Attribute type mapping.
37
38
  def self.swagger_types
38
39
  {
39
- :'successful' => :'BOOLEAN',
40
40
  :'page_number' => :'Integer',
41
+ :'successful' => :'BOOLEAN',
41
42
  :'words' => :'Array<OcrWordElement>'
42
43
  }
43
44
  end
@@ -50,14 +51,14 @@ module CloudmersiveOcrApiClient
50
51
  # convert string to symbol for hash key
51
52
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
52
53
 
53
- if attributes.has_key?(:'Successful')
54
- self.successful = attributes[:'Successful']
55
- end
56
-
57
54
  if attributes.has_key?(:'PageNumber')
58
55
  self.page_number = attributes[:'PageNumber']
59
56
  end
60
57
 
58
+ if attributes.has_key?(:'Successful')
59
+ self.successful = attributes[:'Successful']
60
+ end
61
+
61
62
  if attributes.has_key?(:'Words')
62
63
  if (value = attributes[:'Words']).is_a?(Array)
63
64
  self.words = value
@@ -84,8 +85,8 @@ module CloudmersiveOcrApiClient
84
85
  def ==(o)
85
86
  return true if self.equal?(o)
86
87
  self.class == o.class &&
87
- successful == o.successful &&
88
88
  page_number == o.page_number &&
89
+ successful == o.successful &&
89
90
  words == o.words
90
91
  end
91
92
 
@@ -98,7 +99,7 @@ module CloudmersiveOcrApiClient
98
99
  # Calculates hash code according to all attributes.
99
100
  # @return [Fixnum] Hash code
100
101
  def hash
101
- [successful, page_number, words].hash
102
+ [page_number, successful, words].hash
102
103
  end
103
104
 
104
105
  # Builds the object from hash
@@ -30,6 +30,9 @@ module CloudmersiveOcrApiClient
30
30
  # Height of the word in pixels
31
31
  attr_accessor :height
32
32
 
33
+ # Points that form the bounding polygon around the text
34
+ attr_accessor :bounding_points
35
+
33
36
  # Confidence level of the machine learning result; possible values are 0.0 (lowest accuracy) - 1.0 (highest accuracy)
34
37
  attr_accessor :confidence_level
35
38
 
@@ -42,6 +45,7 @@ module CloudmersiveOcrApiClient
42
45
  :'y_top' => :'YTop',
43
46
  :'width' => :'Width',
44
47
  :'height' => :'Height',
48
+ :'bounding_points' => :'BoundingPoints',
45
49
  :'confidence_level' => :'ConfidenceLevel'
46
50
  }
47
51
  end
@@ -54,6 +58,7 @@ module CloudmersiveOcrApiClient
54
58
  :'y_top' => :'Integer',
55
59
  :'width' => :'Integer',
56
60
  :'height' => :'Integer',
61
+ :'bounding_points' => :'Array<Point>',
57
62
  :'confidence_level' => :'Float'
58
63
  }
59
64
  end
@@ -86,6 +91,12 @@ module CloudmersiveOcrApiClient
86
91
  self.height = attributes[:'Height']
87
92
  end
88
93
 
94
+ if attributes.has_key?(:'BoundingPoints')
95
+ if (value = attributes[:'BoundingPoints']).is_a?(Array)
96
+ self.bounding_points = value
97
+ end
98
+ end
99
+
89
100
  if attributes.has_key?(:'ConfidenceLevel')
90
101
  self.confidence_level = attributes[:'ConfidenceLevel']
91
102
  end
@@ -115,6 +126,7 @@ module CloudmersiveOcrApiClient
115
126
  y_top == o.y_top &&
116
127
  width == o.width &&
117
128
  height == o.height &&
129
+ bounding_points == o.bounding_points &&
118
130
  confidence_level == o.confidence_level
119
131
  end
120
132
 
@@ -127,7 +139,7 @@ module CloudmersiveOcrApiClient
127
139
  # Calculates hash code according to all attributes.
128
140
  # @return [Fixnum] Hash code
129
141
  def hash
130
- [text, x_left, y_top, width, height, confidence_level].hash
142
+ [text, x_left, y_top, width, height, bounding_points, confidence_level].hash
131
143
  end
132
144
 
133
145
  # Builds the object from hash
@@ -15,8 +15,10 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # Response from an OCR to lines with location operation. Includes the confience rating and converted text result, along with the locations of the lines in the pages.
17
17
  class PdfToLinesWithLocationResult
18
+ # True if successful, false otherwise
18
19
  attr_accessor :successful
19
20
 
21
+ # OCR results for each page
20
22
  attr_accessor :ocr_pages
21
23
 
22
24
 
@@ -15,8 +15,10 @@ require 'date'
15
15
  module CloudmersiveOcrApiClient
16
16
  # Response from an OCR to text operation. Includes the confidence rating and converted text result.
17
17
  class PdfToTextResponse
18
+ # True if successful, false otherwise
18
19
  attr_accessor :successful
19
20
 
21
+ # Page OCR results
20
22
  attr_accessor :ocr_pages
21
23
 
22
24