cloudmersive-ocr-api-client 1.3.9 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -4
- data/docs/FieldResult.md +9 -0
- data/docs/FormDefinitionTemplate.md +8 -0
- data/docs/FormFieldDefinition.md +20 -0
- data/docs/FormRecognitionResult.md +9 -0
- data/docs/ImageOcrApi.md +67 -0
- data/docs/ReceiptLineItem.md +9 -0
- data/docs/ReceiptRecognitionResult.md +2 -0
- data/lib/cloudmersive-ocr-api-client.rb +5 -0
- data/lib/cloudmersive-ocr-api-client/api/image_ocr_api.rb +71 -0
- data/lib/cloudmersive-ocr-api-client/models/field_result.rb +199 -0
- data/lib/cloudmersive-ocr-api-client/models/form_definition_template.rb +190 -0
- data/lib/cloudmersive-ocr-api-client/models/form_field_definition.rb +298 -0
- data/lib/cloudmersive-ocr-api-client/models/form_recognition_result.rb +199 -0
- data/lib/cloudmersive-ocr-api-client/models/receipt_line_item.rb +197 -0
- data/lib/cloudmersive-ocr-api-client/models/receipt_recognition_result.rb +21 -1
- data/lib/cloudmersive-ocr-api-client/version.rb +1 -1
- data/spec/api/image_ocr_api_spec.rb +17 -0
- data/spec/models/field_result_spec.rb +48 -0
- data/spec/models/form_definition_template_spec.rb +42 -0
- data/spec/models/form_field_definition_spec.rb +114 -0
- data/spec/models/form_recognition_result_spec.rb +48 -0
- data/spec/models/receipt_line_item_spec.rb +48 -0
- data/spec/models/receipt_recognition_result_spec.rb +12 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 316f1c944a6eefef693a48d0fccf2f55451d019cd4d1ac6d55f43a585a211d86
|
4
|
+
data.tar.gz: 9d3049879d84d9f776c16651859cd59325fcedda5f646830676c25f2f9a09870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80f7855f040cc9efbe0805210a3e9ef2dff18baaa402e07e137321bf1611285d5be4c01494394bec46929fdfc81f69871b0dead8a05e7dfcd2df4f472062eb57
|
7
|
+
data.tar.gz: 5c1ba2fac68dda25683805b8af4ee01ace4f84fc574b8c34bf019febb013cddc841ebe3e6f5a3cf8a7ddab8776449ca713cce5b25bdf1564a08eebd885ec1b97
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ The powerful Optical Character Recognition (OCR) APIs let you convert scanned im
|
|
7
7
|
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
8
8
|
|
9
9
|
- API version: v1
|
10
|
-
- Package version: 1.
|
10
|
+
- Package version: 1.4.0
|
11
11
|
- Build package: io.swagger.codegen.languages.RubyClientCodegen
|
12
12
|
|
13
13
|
## Installation
|
@@ -23,15 +23,15 @@ gem build cloudmersive-ocr-api-client.gemspec
|
|
23
23
|
Then either install the gem locally:
|
24
24
|
|
25
25
|
```shell
|
26
|
-
gem install ./cloudmersive-ocr-api-client-1.
|
26
|
+
gem install ./cloudmersive-ocr-api-client-1.4.0.gem
|
27
27
|
```
|
28
|
-
(for development, run `gem install --dev ./cloudmersive-ocr-api-client-1.
|
28
|
+
(for development, run `gem install --dev ./cloudmersive-ocr-api-client-1.4.0.gem` to install the development dependencies)
|
29
29
|
|
30
30
|
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
|
31
31
|
|
32
32
|
Finally add this to the Gemfile:
|
33
33
|
|
34
|
-
gem 'cloudmersive-ocr-api-client', '~> 1.
|
34
|
+
gem 'cloudmersive-ocr-api-client', '~> 1.4.0'
|
35
35
|
|
36
36
|
### Install from Git
|
37
37
|
|
@@ -90,6 +90,7 @@ Class | Method | HTTP request | Description
|
|
90
90
|
*CloudmersiveOcrApiClient::ImageOcrApi* | [**image_ocr_image_lines_with_location**](docs/ImageOcrApi.md#image_ocr_image_lines_with_location) | **POST** /ocr/image/to/lines-with-location | Convert a scanned image into words with location
|
91
91
|
*CloudmersiveOcrApiClient::ImageOcrApi* | [**image_ocr_image_words_with_location**](docs/ImageOcrApi.md#image_ocr_image_words_with_location) | **POST** /ocr/image/to/words-with-location | Convert a scanned image into words with location
|
92
92
|
*CloudmersiveOcrApiClient::ImageOcrApi* | [**image_ocr_photo_recognize_business_card**](docs/ImageOcrApi.md#image_ocr_photo_recognize_business_card) | **POST** /ocr/photo/recognize/business-card | Recognize a photo of a business card, extract key business information
|
93
|
+
*CloudmersiveOcrApiClient::ImageOcrApi* | [**image_ocr_photo_recognize_form**](docs/ImageOcrApi.md#image_ocr_photo_recognize_form) | **POST** /ocr/photo/recognize/form | Recognize a photo of a form, extract key fields and business information
|
93
94
|
*CloudmersiveOcrApiClient::ImageOcrApi* | [**image_ocr_photo_recognize_receipt**](docs/ImageOcrApi.md#image_ocr_photo_recognize_receipt) | **POST** /ocr/photo/recognize/receipt | Recognize a photo of a receipt, extract key business information
|
94
95
|
*CloudmersiveOcrApiClient::ImageOcrApi* | [**image_ocr_photo_to_text**](docs/ImageOcrApi.md#image_ocr_photo_to_text) | **POST** /ocr/photo/toText | Convert a photo of a document into text
|
95
96
|
*CloudmersiveOcrApiClient::ImageOcrApi* | [**image_ocr_photo_words_with_location**](docs/ImageOcrApi.md#image_ocr_photo_words_with_location) | **POST** /ocr/photo/to/words-with-location | Convert a photo of a document or receipt into words with location
|
@@ -108,6 +109,10 @@ Class | Method | HTTP request | Description
|
|
108
109
|
## Documentation for Models
|
109
110
|
|
110
111
|
- [CloudmersiveOcrApiClient::BusinessCardRecognitionResult](docs/BusinessCardRecognitionResult.md)
|
112
|
+
- [CloudmersiveOcrApiClient::FieldResult](docs/FieldResult.md)
|
113
|
+
- [CloudmersiveOcrApiClient::FormDefinitionTemplate](docs/FormDefinitionTemplate.md)
|
114
|
+
- [CloudmersiveOcrApiClient::FormFieldDefinition](docs/FormFieldDefinition.md)
|
115
|
+
- [CloudmersiveOcrApiClient::FormRecognitionResult](docs/FormRecognitionResult.md)
|
111
116
|
- [CloudmersiveOcrApiClient::GetPageAngleResult](docs/GetPageAngleResult.md)
|
112
117
|
- [CloudmersiveOcrApiClient::ImageToLinesWithLocationResult](docs/ImageToLinesWithLocationResult.md)
|
113
118
|
- [CloudmersiveOcrApiClient::ImageToTextResponse](docs/ImageToTextResponse.md)
|
@@ -122,6 +127,7 @@ Class | Method | HTTP request | Description
|
|
122
127
|
- [CloudmersiveOcrApiClient::PdfToTextResponse](docs/PdfToTextResponse.md)
|
123
128
|
- [CloudmersiveOcrApiClient::PdfToWordsWithLocationResult](docs/PdfToWordsWithLocationResult.md)
|
124
129
|
- [CloudmersiveOcrApiClient::PhotoToWordsWithLocationResult](docs/PhotoToWordsWithLocationResult.md)
|
130
|
+
- [CloudmersiveOcrApiClient::ReceiptLineItem](docs/ReceiptLineItem.md)
|
125
131
|
- [CloudmersiveOcrApiClient::ReceiptRecognitionResult](docs/ReceiptRecognitionResult.md)
|
126
132
|
|
127
133
|
|
data/docs/FieldResult.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# CloudmersiveOcrApiClient::FieldResult
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
Name | Type | Description | Notes
|
5
|
+
------------ | ------------- | ------------- | -------------
|
6
|
+
**target_field** | [**FormFieldDefinition**](FormFieldDefinition.md) | | [optional]
|
7
|
+
**field_values** | [**Array<OcrPhotoTextElement>**](OcrPhotoTextElement.md) | | [optional]
|
8
|
+
|
9
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# CloudmersiveOcrApiClient::FormDefinitionTemplate
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
Name | Type | Description | Notes
|
5
|
+
------------ | ------------- | ------------- | -------------
|
6
|
+
**field_definitions** | [**Array<FormFieldDefinition>**](FormFieldDefinition.md) | | [optional]
|
7
|
+
|
8
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# CloudmersiveOcrApiClient::FormFieldDefinition
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
Name | Type | Description | Notes
|
5
|
+
------------ | ------------- | ------------- | -------------
|
6
|
+
**field_id** | **String** | | [optional]
|
7
|
+
**left_anchor** | **String** | | [optional]
|
8
|
+
**top_anchor** | **String** | | [optional]
|
9
|
+
**anchor_mode** | **String** | | [optional]
|
10
|
+
**data_type** | **String** | | [optional]
|
11
|
+
**target_digit_count** | **Integer** | | [optional]
|
12
|
+
**minimum_character_count** | **Integer** | | [optional]
|
13
|
+
**allow_numeric_digits** | **BOOLEAN** | | [optional]
|
14
|
+
**vertical_alignment_type** | **String** | | [optional]
|
15
|
+
**horizontal_alignment_type** | **String** | | [optional]
|
16
|
+
**target_field_width_relative** | **Float** | | [optional]
|
17
|
+
**target_field_height_relative** | **Float** | | [optional]
|
18
|
+
**ignore** | **Array<String>** | | [optional]
|
19
|
+
|
20
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# CloudmersiveOcrApiClient::FormRecognitionResult
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
Name | Type | Description | Notes
|
5
|
+
------------ | ------------- | ------------- | -------------
|
6
|
+
**successful** | **BOOLEAN** | | [optional]
|
7
|
+
**field_value_extraction_result** | [**Array<FieldResult>**](FieldResult.md) | | [optional]
|
8
|
+
|
9
|
+
|
data/docs/ImageOcrApi.md
CHANGED
@@ -7,6 +7,7 @@ Method | HTTP request | Description
|
|
7
7
|
[**image_ocr_image_lines_with_location**](ImageOcrApi.md#image_ocr_image_lines_with_location) | **POST** /ocr/image/to/lines-with-location | Convert a scanned image into words with location
|
8
8
|
[**image_ocr_image_words_with_location**](ImageOcrApi.md#image_ocr_image_words_with_location) | **POST** /ocr/image/to/words-with-location | Convert a scanned image into words with location
|
9
9
|
[**image_ocr_photo_recognize_business_card**](ImageOcrApi.md#image_ocr_photo_recognize_business_card) | **POST** /ocr/photo/recognize/business-card | Recognize a photo of a business card, extract key business information
|
10
|
+
[**image_ocr_photo_recognize_form**](ImageOcrApi.md#image_ocr_photo_recognize_form) | **POST** /ocr/photo/recognize/form | Recognize a photo of a form, extract key fields and business information
|
10
11
|
[**image_ocr_photo_recognize_receipt**](ImageOcrApi.md#image_ocr_photo_recognize_receipt) | **POST** /ocr/photo/recognize/receipt | Recognize a photo of a receipt, extract key business information
|
11
12
|
[**image_ocr_photo_to_text**](ImageOcrApi.md#image_ocr_photo_to_text) | **POST** /ocr/photo/toText | Convert a photo of a document into text
|
12
13
|
[**image_ocr_photo_words_with_location**](ImageOcrApi.md#image_ocr_photo_words_with_location) | **POST** /ocr/photo/to/words-with-location | Convert a photo of a document or receipt into words with location
|
@@ -187,6 +188,68 @@ Name | Type | Description | Notes
|
|
187
188
|
|
188
189
|
|
189
190
|
|
191
|
+
# **image_ocr_photo_recognize_form**
|
192
|
+
> FormRecognitionResult image_ocr_photo_recognize_form(image_file, opts)
|
193
|
+
|
194
|
+
Recognize a photo of a form, extract key fields and business information
|
195
|
+
|
196
|
+
Analyzes a photograph of a form as input, and outputs key business fields and information. Customzie data to be extracted by defining fields for the form.
|
197
|
+
|
198
|
+
### Example
|
199
|
+
```ruby
|
200
|
+
# load the gem
|
201
|
+
require 'cloudmersive-ocr-api-client'
|
202
|
+
# setup authorization
|
203
|
+
CloudmersiveOcrApiClient.configure do |config|
|
204
|
+
# Configure API key authorization: Apikey
|
205
|
+
config.api_key['Apikey'] = 'YOUR API KEY'
|
206
|
+
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
|
207
|
+
#config.api_key_prefix['Apikey'] = 'Bearer'
|
208
|
+
end
|
209
|
+
|
210
|
+
api_instance = CloudmersiveOcrApiClient::ImageOcrApi.new
|
211
|
+
|
212
|
+
image_file = File.new("/path/to/file.txt") # File | Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
|
213
|
+
|
214
|
+
opts = {
|
215
|
+
form_template_definition: "form_template_definition_example", # String | Form field definitions
|
216
|
+
recognition_mode: "recognition_mode_example", # String | Optional, enable advanced recognition mode by specifying 'Advanced', enable handwriting recognition by specifying 'EnableHandwriting'. Default is disabled.
|
217
|
+
language: "language_example" # String | Optional, language of the input document, default is English (ENG). Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish)
|
218
|
+
}
|
219
|
+
|
220
|
+
begin
|
221
|
+
#Recognize a photo of a form, extract key fields and business information
|
222
|
+
result = api_instance.image_ocr_photo_recognize_form(image_file, opts)
|
223
|
+
p result
|
224
|
+
rescue CloudmersiveOcrApiClient::ApiError => e
|
225
|
+
puts "Exception when calling ImageOcrApi->image_ocr_photo_recognize_form: #{e}"
|
226
|
+
end
|
227
|
+
```
|
228
|
+
|
229
|
+
### Parameters
|
230
|
+
|
231
|
+
Name | Type | Description | Notes
|
232
|
+
------------- | ------------- | ------------- | -------------
|
233
|
+
**image_file** | **File**| Image file to perform OCR on. Common file formats such as PNG, JPEG are supported. |
|
234
|
+
**form_template_definition** | **String**| Form field definitions | [optional]
|
235
|
+
**recognition_mode** | **String**| Optional, enable advanced recognition mode by specifying 'Advanced', enable handwriting recognition by specifying 'EnableHandwriting'. Default is disabled. | [optional]
|
236
|
+
**language** | **String**| Optional, language of the input document, default is English (ENG). Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish) | [optional]
|
237
|
+
|
238
|
+
### Return type
|
239
|
+
|
240
|
+
[**FormRecognitionResult**](FormRecognitionResult.md)
|
241
|
+
|
242
|
+
### Authorization
|
243
|
+
|
244
|
+
[Apikey](../README.md#Apikey)
|
245
|
+
|
246
|
+
### HTTP request headers
|
247
|
+
|
248
|
+
- **Content-Type**: multipart/form-data
|
249
|
+
- **Accept**: application/json, text/json, application/xml, text/xml
|
250
|
+
|
251
|
+
|
252
|
+
|
190
253
|
# **image_ocr_photo_recognize_receipt**
|
191
254
|
> ReceiptRecognitionResult image_ocr_photo_recognize_receipt(image_file, opts)
|
192
255
|
|
@@ -211,6 +274,8 @@ api_instance = CloudmersiveOcrApiClient::ImageOcrApi.new
|
|
211
274
|
image_file = File.new("/path/to/file.txt") # File | Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
|
212
275
|
|
213
276
|
opts = {
|
277
|
+
form_template_definition: "form_template_definition_example", # String | Form field definitions
|
278
|
+
recognition_mode: "recognition_mode_example", # String | Optional, enable advanced recognition mode by specifying 'Advanced', enable handwriting recognition by specifying 'EnableHandwriting'. Default is disabled.
|
214
279
|
language: "language_example" # String | Optional, language of the input document, default is English (ENG). Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish)
|
215
280
|
}
|
216
281
|
|
@@ -228,6 +293,8 @@ end
|
|
228
293
|
Name | Type | Description | Notes
|
229
294
|
------------- | ------------- | ------------- | -------------
|
230
295
|
**image_file** | **File**| Image file to perform OCR on. Common file formats such as PNG, JPEG are supported. |
|
296
|
+
**form_template_definition** | **String**| Form field definitions | [optional]
|
297
|
+
**recognition_mode** | **String**| Optional, enable advanced recognition mode by specifying 'Advanced', enable handwriting recognition by specifying 'EnableHandwriting'. Default is disabled. | [optional]
|
231
298
|
**language** | **String**| Optional, language of the input document, default is English (ENG). Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish) | [optional]
|
232
299
|
|
233
300
|
### Return type
|
@@ -6,8 +6,10 @@ Name | Type | Description | Notes
|
|
6
6
|
**successful** | **BOOLEAN** | | [optional]
|
7
7
|
**timestamp** | **DateTime** | | [optional]
|
8
8
|
**business_name** | **String** | | [optional]
|
9
|
+
**business_website** | **String** | | [optional]
|
9
10
|
**address_string** | **String** | | [optional]
|
10
11
|
**phone_number** | **String** | | [optional]
|
12
|
+
**receipt_items** | [**Array<ReceiptLineItem>**](ReceiptLineItem.md) | | [optional]
|
11
13
|
**receipt_total** | **Float** | | [optional]
|
12
14
|
|
13
15
|
|
@@ -18,6 +18,10 @@ require 'cloudmersive-ocr-api-client/configuration'
|
|
18
18
|
|
19
19
|
# Models
|
20
20
|
require 'cloudmersive-ocr-api-client/models/business_card_recognition_result'
|
21
|
+
require 'cloudmersive-ocr-api-client/models/field_result'
|
22
|
+
require 'cloudmersive-ocr-api-client/models/form_definition_template'
|
23
|
+
require 'cloudmersive-ocr-api-client/models/form_field_definition'
|
24
|
+
require 'cloudmersive-ocr-api-client/models/form_recognition_result'
|
21
25
|
require 'cloudmersive-ocr-api-client/models/get_page_angle_result'
|
22
26
|
require 'cloudmersive-ocr-api-client/models/image_to_lines_with_location_result'
|
23
27
|
require 'cloudmersive-ocr-api-client/models/image_to_text_response'
|
@@ -32,6 +36,7 @@ require 'cloudmersive-ocr-api-client/models/pdf_to_lines_with_location_result'
|
|
32
36
|
require 'cloudmersive-ocr-api-client/models/pdf_to_text_response'
|
33
37
|
require 'cloudmersive-ocr-api-client/models/pdf_to_words_with_location_result'
|
34
38
|
require 'cloudmersive-ocr-api-client/models/photo_to_words_with_location_result'
|
39
|
+
require 'cloudmersive-ocr-api-client/models/receipt_line_item'
|
35
40
|
require 'cloudmersive-ocr-api-client/models/receipt_recognition_result'
|
36
41
|
|
37
42
|
# APIs
|
@@ -200,10 +200,77 @@ module CloudmersiveOcrApiClient
|
|
200
200
|
return data, status_code, headers
|
201
201
|
end
|
202
202
|
|
203
|
+
# Recognize a photo of a form, extract key fields and business information
|
204
|
+
# Analyzes a photograph of a form as input, and outputs key business fields and information. Customzie data to be extracted by defining fields for the form.
|
205
|
+
# @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
|
206
|
+
# @param [Hash] opts the optional parameters
|
207
|
+
# @option opts [String] :form_template_definition Form field definitions
|
208
|
+
# @option opts [String] :recognition_mode Optional, enable advanced recognition mode by specifying 'Advanced', enable handwriting recognition by specifying 'EnableHandwriting'. Default is disabled.
|
209
|
+
# @option opts [String] :language Optional, language of the input document, default is English (ENG). Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish)
|
210
|
+
# @return [FormRecognitionResult]
|
211
|
+
def image_ocr_photo_recognize_form(image_file, opts = {})
|
212
|
+
data, _status_code, _headers = image_ocr_photo_recognize_form_with_http_info(image_file, opts)
|
213
|
+
return data
|
214
|
+
end
|
215
|
+
|
216
|
+
# Recognize a photo of a form, extract key fields and business information
|
217
|
+
# Analyzes a photograph of a form as input, and outputs key business fields and information. Customzie data to be extracted by defining fields for the form.
|
218
|
+
# @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
|
219
|
+
# @param [Hash] opts the optional parameters
|
220
|
+
# @option opts [String] :form_template_definition Form field definitions
|
221
|
+
# @option opts [String] :recognition_mode Optional, enable advanced recognition mode by specifying 'Advanced', enable handwriting recognition by specifying 'EnableHandwriting'. Default is disabled.
|
222
|
+
# @option opts [String] :language Optional, language of the input document, default is English (ENG). Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish)
|
223
|
+
# @return [Array<(FormRecognitionResult, Fixnum, Hash)>] FormRecognitionResult data, response status code and response headers
|
224
|
+
def image_ocr_photo_recognize_form_with_http_info(image_file, opts = {})
|
225
|
+
if @api_client.config.debugging
|
226
|
+
@api_client.config.logger.debug "Calling API: ImageOcrApi.image_ocr_photo_recognize_form ..."
|
227
|
+
end
|
228
|
+
# verify the required parameter 'image_file' is set
|
229
|
+
if @api_client.config.client_side_validation && image_file.nil?
|
230
|
+
fail ArgumentError, "Missing the required parameter 'image_file' when calling ImageOcrApi.image_ocr_photo_recognize_form"
|
231
|
+
end
|
232
|
+
# resource path
|
233
|
+
local_var_path = "/ocr/photo/recognize/form"
|
234
|
+
|
235
|
+
# query parameters
|
236
|
+
query_params = {}
|
237
|
+
|
238
|
+
# header parameters
|
239
|
+
header_params = {}
|
240
|
+
# HTTP header 'Accept' (if needed)
|
241
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
|
242
|
+
# HTTP header 'Content-Type'
|
243
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
|
244
|
+
header_params[:'formTemplateDefinition'] = opts[:'form_template_definition'] if !opts[:'form_template_definition'].nil?
|
245
|
+
header_params[:'recognitionMode'] = opts[:'recognition_mode'] if !opts[:'recognition_mode'].nil?
|
246
|
+
header_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?
|
247
|
+
|
248
|
+
# form parameters
|
249
|
+
form_params = {}
|
250
|
+
form_params["imageFile"] = image_file
|
251
|
+
|
252
|
+
# http body (model)
|
253
|
+
post_body = nil
|
254
|
+
auth_names = ['Apikey']
|
255
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
256
|
+
:header_params => header_params,
|
257
|
+
:query_params => query_params,
|
258
|
+
:form_params => form_params,
|
259
|
+
:body => post_body,
|
260
|
+
:auth_names => auth_names,
|
261
|
+
:return_type => 'FormRecognitionResult')
|
262
|
+
if @api_client.config.debugging
|
263
|
+
@api_client.config.logger.debug "API called: ImageOcrApi#image_ocr_photo_recognize_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
264
|
+
end
|
265
|
+
return data, status_code, headers
|
266
|
+
end
|
267
|
+
|
203
268
|
# Recognize a photo of a receipt, extract key business information
|
204
269
|
# Analyzes a photograph of a receipt as input, and outputs key business information such as the name of the business, the address of the business, the phone number of the business, the total of the receipt, the date of the receipt, and more.
|
205
270
|
# @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
|
206
271
|
# @param [Hash] opts the optional parameters
|
272
|
+
# @option opts [String] :form_template_definition Form field definitions
|
273
|
+
# @option opts [String] :recognition_mode Optional, enable advanced recognition mode by specifying 'Advanced', enable handwriting recognition by specifying 'EnableHandwriting'. Default is disabled.
|
207
274
|
# @option opts [String] :language Optional, language of the input document, default is English (ENG). Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish)
|
208
275
|
# @return [ReceiptRecognitionResult]
|
209
276
|
def image_ocr_photo_recognize_receipt(image_file, opts = {})
|
@@ -215,6 +282,8 @@ module CloudmersiveOcrApiClient
|
|
215
282
|
# Analyzes a photograph of a receipt as input, and outputs key business information such as the name of the business, the address of the business, the phone number of the business, the total of the receipt, the date of the receipt, and more.
|
216
283
|
# @param image_file Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
|
217
284
|
# @param [Hash] opts the optional parameters
|
285
|
+
# @option opts [String] :form_template_definition Form field definitions
|
286
|
+
# @option opts [String] :recognition_mode Optional, enable advanced recognition mode by specifying 'Advanced', enable handwriting recognition by specifying 'EnableHandwriting'. Default is disabled.
|
218
287
|
# @option opts [String] :language Optional, language of the input document, default is English (ENG). Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish)
|
219
288
|
# @return [Array<(ReceiptRecognitionResult, Fixnum, Hash)>] ReceiptRecognitionResult data, response status code and response headers
|
220
289
|
def image_ocr_photo_recognize_receipt_with_http_info(image_file, opts = {})
|
@@ -237,6 +306,8 @@ module CloudmersiveOcrApiClient
|
|
237
306
|
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
|
238
307
|
# HTTP header 'Content-Type'
|
239
308
|
header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
|
309
|
+
header_params[:'formTemplateDefinition'] = opts[:'form_template_definition'] if !opts[:'form_template_definition'].nil?
|
310
|
+
header_params[:'recognitionMode'] = opts[:'recognition_mode'] if !opts[:'recognition_mode'].nil?
|
240
311
|
header_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?
|
241
312
|
|
242
313
|
# form parameters
|
@@ -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
|
+
# A pairing target field and actual value read from form
|
17
|
+
class FieldResult
|
18
|
+
attr_accessor :target_field
|
19
|
+
|
20
|
+
attr_accessor :field_values
|
21
|
+
|
22
|
+
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
+
def self.attribute_map
|
25
|
+
{
|
26
|
+
:'target_field' => :'TargetField',
|
27
|
+
:'field_values' => :'FieldValues'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attribute type mapping.
|
32
|
+
def self.swagger_types
|
33
|
+
{
|
34
|
+
:'target_field' => :'FormFieldDefinition',
|
35
|
+
:'field_values' => :'Array<OcrPhotoTextElement>'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Initializes the object
|
40
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
41
|
+
def initialize(attributes = {})
|
42
|
+
return unless attributes.is_a?(Hash)
|
43
|
+
|
44
|
+
# convert string to symbol for hash key
|
45
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
46
|
+
|
47
|
+
if attributes.has_key?(:'TargetField')
|
48
|
+
self.target_field = attributes[:'TargetField']
|
49
|
+
end
|
50
|
+
|
51
|
+
if attributes.has_key?(:'FieldValues')
|
52
|
+
if (value = attributes[:'FieldValues']).is_a?(Array)
|
53
|
+
self.field_values = value
|
54
|
+
end
|
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
|
+
target_field == o.target_field &&
|
78
|
+
field_values == o.field_values
|
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
|
+
[target_field, field_values].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
|