# 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).
import oci
from datetime import datetime
# 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.config.from_file()
# Initialize service client with default config file
ai_document_client = oci.ai_document.AIServiceDocumentClient(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(
analyze_document_details=oci.ai_document.models.AnalyzeDocumentDetails(
features=[
oci.ai_document.models.DocumentClassificationFeature(
feature_type="DOCUMENT_CLASSIFICATION",
max_results=926,
model_id="ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value",
tenancy_id="ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value")],
document=oci.ai_document.models.InlineDocumentDetails(
source="INLINE",
data="DVlcEVr5H6K4fyehGKr7",
page_range=["EXAMPLE--Value"]),
compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
output_location=oci.ai_document.models.OutputLocation(
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.ai_document.models.AnalyzeDocumentResult(
document_metadata=oci.ai_document.models.DocumentMetadata(
page_count=703,
mime_type="EXAMPLE-mimeType-Value"),
pages=[
oci.ai_document.models.Page(
page_number=140,
dimensions=oci.ai_document.models.Dimensions(
width=8598.904,
height=6801.139,
unit="INCH"),
detected_document_types=[
oci.ai_document.models.DetectedDocumentType(
document_type="EXAMPLE-documentType-Value",
confidence=0.2361151,
document_id="ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value")],
detected_languages=[
oci.ai_document.models.DetectedLanguage(
language="EXAMPLE-language-Value",
confidence=0.6452008)],
words=[
oci.ai_document.models.Word(
text="EXAMPLE-text-Value",
confidence=0.89703614,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.6347457,
y=0.34505373)]))],
lines=[
oci.ai_document.models.Line(
text="EXAMPLE-text-Value",
confidence=0.4139248,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.7980748,
y=0.18187869)]),
word_indexes=[192])],
tables=[
oci.ai_document.models.Table(
row_count=690,
column_count=398,
header_rows=[
oci.ai_document.models.TableRow(
cells=[
oci.ai_document.models.Cell(
text="EXAMPLE-text-Value",
row_index=485,
column_index=908,
confidence=0.8098093,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.37790602,
y=0.3139165)]),
word_indexes=[196])])],
confidence=0.54962003,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.68222594,
y=0.34030187)]))],
document_fields=[
oci.ai_document.models.DocumentField(
field_type="LINE_ITEM_GROUP",
field_value=oci.ai_document.models.ValueDate(
value_type="DATE",
confidence=0.073206306,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.1410889,
y=0.203111)]),
word_indexes=[127],
value=datetime.strptime(
"2012-03-26T08:15:41.489Z",
"%Y-%m-%dT%H:%M:%S.%fZ"),
text="EXAMPLE-text-Value",
normalized_value="EXAMPLE-normalizedValue-Value",
normalized_confidence=0.42452675),
field_label=oci.ai_document.models.FieldLabel(
name="EXAMPLE-name-Value",
confidence=0.26406038),
field_name=oci.ai_document.models.FieldName(
name="EXAMPLE-name-Value",
confidence=0.27803117,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.74348044,
y=0.035226166)]),
word_indexes=[116]))],
signatures=[
oci.ai_document.models.Signature(
confidence=0.98944896,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.538474,
y=0.49598473)]))],
bar_codes=[
oci.ai_document.models.BarCode(
confidence=0.56144947,
value="EXAMPLE-value-Value",
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.2476762,
y=0.9435228)]),
code_type="EXAMPLE-codeType-Value")],
selection_marks=[
oci.ai_document.models.SelectionMark(
state="SELECTED",
confidence=0.9935627,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.16390628,
y=0.06763345)]))])],
detected_document_types=[
oci.ai_document.models.DetectedDocumentType(
document_type="EXAMPLE-documentType-Value",
confidence=0.63630563,
document_id="ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value")],
detected_languages=[
oci.ai_document.models.DetectedLanguage(
language="EXAMPLE-language-Value",
confidence=0.6410271)],
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.ai_document.models.ProcessingError(
code="EXAMPLE-code-Value",
message="EXAMPLE-message-Value")],
searchable_pdf="U7mSwzSLnH4908UpqfCD")),
if_match="EXAMPLE-ifMatch-Value",
opc_request_id="VP1KJSN8VTSWFG62G7WI<unique_ID>")
# Get the data from response
print(analyze_document_response.data)