# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).
require 'oci'
# Create a default config using DEFAULT profile in default location
# Refer to https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File for more info
config = OCI::ConfigFileLoader.load_config
# Initialize service client with default config file
ai_document_client =
OCI::AiDocument::AIServiceDocumentClient.new(config: config)
# Send the request to service, some parameters are not required, see API doc for more info
analyze_document_response =
ai_document_client.analyze_document(
OCI::AiDocument::Models::AnalyzeDocumentDetails.new(
features: [
OCI::AiDocument::Models::DocumentKeyValueExtractionFeature.new(
feature_type: 'KEY_VALUE_EXTRACTION',
model_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value',
tenancy_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value'
)
],
document:
OCI::AiDocument::Models::ObjectStorageDocumentDetails.new(
source: 'OBJECT_STORAGE',
namespace_name: 'EXAMPLE-namespaceName-Value',
bucket_name: 'EXAMPLE-bucketName-Value',
object_name: 'EXAMPLE-objectName-Value',
page_range: %w[EXAMPLE--Value]
),
compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
output_location:
OCI::AiDocument::Models::OutputLocation.new(
namespace_name: 'EXAMPLE-namespaceName-Value',
bucket_name: 'EXAMPLE-bucketName-Value',
prefix: 'EXAMPLE-prefix-Value'
),
language: 'EXAMPLE-language-Value',
document_type: 'HEALTH_INSURANCE_ID',
ocr_data:
OCI::AiDocument::Models::AnalyzeDocumentResult.new(
document_metadata:
OCI::AiDocument::Models::DocumentMetadata.new(
page_count: 658, mime_type: 'EXAMPLE-mimeType-Value'
),
pages: [
OCI::AiDocument::Models::Page.new(
page_number: 499,
dimensions:
OCI::AiDocument::Models::Dimensions.new(
width: 2204.7222, height: 7682.858, unit: 'INCH'
),
detected_document_types: [
OCI::AiDocument::Models::DetectedDocumentType.new(
document_type: 'EXAMPLE-documentType-Value',
confidence: 0.80285674,
document_id:
'ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value'
)
],
detected_languages: [
OCI::AiDocument::Models::DetectedLanguage.new(
language: 'EXAMPLE-language-Value', confidence: 0.43211836
)
],
words: [
OCI::AiDocument::Models::Word.new(
text: 'EXAMPLE-text-Value',
confidence: 0.6554321,
bounding_polygon:
OCI::AiDocument::Models::BoundingPolygon.new(
normalized_vertices: [
OCI::AiDocument::Models::NormalizedVertex.new(
x: 0.6725511, y: 0.030065954
)
]
)
)
],
lines: [
OCI::AiDocument::Models::Line.new(
text: 'EXAMPLE-text-Value',
confidence: 0.40056372,
bounding_polygon:
OCI::AiDocument::Models::BoundingPolygon.new(
normalized_vertices: [
OCI::AiDocument::Models::NormalizedVertex.new(
x: 0.23701948, y: 0.7572835
)
]
),
word_indexes: [77]
)
],
tables: [
OCI::AiDocument::Models::Table.new(
row_count: 488,
column_count: 678,
header_rows: [
OCI::AiDocument::Models::TableRow.new(
cells: [
OCI::AiDocument::Models::Cell.new(
text: 'EXAMPLE-text-Value',
row_index: 56,
column_index: 994,
confidence: 0.4474274,
bounding_polygon:
OCI::AiDocument::Models::BoundingPolygon.new(
normalized_vertices: [
OCI::AiDocument::Models::NormalizedVertex.new(
x: 0.14955759, y: 0.31533659
)
]
),
word_indexes: [845]
)
]
)
],
confidence: 0.031799674,
bounding_polygon:
OCI::AiDocument::Models::BoundingPolygon.new(
normalized_vertices: [
OCI::AiDocument::Models::NormalizedVertex.new(
x: 0.96926, y: 0.7323872
)
]
)
)
],
document_fields: [
OCI::AiDocument::Models::DocumentField.new(
field_type: 'LINE_ITEM',
field_value:
OCI::AiDocument::Models::ValueInteger.new(
value_type: 'INTEGER',
confidence: 0.7070653,
bounding_polygon:
OCI::AiDocument::Models::BoundingPolygon.new(
normalized_vertices: [
OCI::AiDocument::Models::NormalizedVertex.new(
x: 0.3701362, y: 0.121564746
)
]
),
word_indexes: [38],
value: 448,
text: 'EXAMPLE-text-Value',
normalized_value: 'EXAMPLE-normalizedValue-Value',
normalized_confidence: 0.6377586
),
field_label:
OCI::AiDocument::Models::FieldLabel.new(
name: 'EXAMPLE-name-Value', confidence: 0.18942714
),
field_name:
OCI::AiDocument::Models::FieldName.new(
name: 'EXAMPLE-name-Value',
confidence: 0.010871828,
bounding_polygon:
OCI::AiDocument::Models::BoundingPolygon.new(
normalized_vertices: [
OCI::AiDocument::Models::NormalizedVertex.new(
x: 0.7731043, y: 0.54440093
)
]
),
word_indexes: [831]
)
)
],
signatures: [
OCI::AiDocument::Models::Signature.new(
confidence: 0.051778257,
bounding_polygon:
OCI::AiDocument::Models::BoundingPolygon.new(
normalized_vertices: [
OCI::AiDocument::Models::NormalizedVertex.new(
x: 0.87662697, y: 0.6283201
)
]
)
)
],
bar_codes: [
OCI::AiDocument::Models::BarCode.new(
confidence: 0.022303224,
value: 'EXAMPLE-value-Value',
bounding_polygon:
OCI::AiDocument::Models::BoundingPolygon.new(
normalized_vertices: [
OCI::AiDocument::Models::NormalizedVertex.new(
x: 0.90759534, y: 0.91044587
)
]
),
code_type: 'EXAMPLE-codeType-Value'
)
],
selection_marks: [
OCI::AiDocument::Models::SelectionMark.new(
state: 'UNSELECTED',
confidence: 0.6965759,
bounding_polygon:
OCI::AiDocument::Models::BoundingPolygon.new(
normalized_vertices: [
OCI::AiDocument::Models::NormalizedVertex.new(
x: 0.22066593, y: 0.22802961
)
]
)
)
]
)
],
detected_document_types: [
OCI::AiDocument::Models::DetectedDocumentType.new(
document_type: 'EXAMPLE-documentType-Value',
confidence: 0.5512688,
document_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value'
)
],
detected_languages: [
OCI::AiDocument::Models::DetectedLanguage.new(
language: 'EXAMPLE-language-Value', confidence: 0.105899155
)
],
document_classification_model_version:
'EXAMPLE-documentClassificationModelVersion-Value',
language_classification_model_version:
'EXAMPLE-languageClassificationModelVersion-Value',
text_extraction_model_version:
'EXAMPLE-textExtractionModelVersion-Value',
key_value_extraction_model_version:
'EXAMPLE-keyValueExtractionModelVersion-Value',
table_extraction_model_version:
'EXAMPLE-tableExtractionModelVersion-Value',
signature_extraction_model_version:
'EXAMPLE-signatureExtractionModelVersion-Value',
bar_code_extraction_model_version:
'EXAMPLE-barCodeExtractionModelVersion-Value',
errors: [
OCI::AiDocument::Models::ProcessingError.new(
code: 'EXAMPLE-code-Value', message: 'EXAMPLE-message-Value'
)
],
searchable_pdf: '5H6K4fyehGKr7j096hFc'
)
)
)
# Get the data from response
puts "#{analyze_document_response.data}"