# 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.DocumentLanguageClassificationFeature(
feature_type="LANGUAGE_CLASSIFICATION",
max_results=224)],
document=oci.ai_document.models.InlineDocumentDetails(
source="INLINE",
data="6lm4vs5ET6OHtvAbQ1Zx"),
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="CHECK",
ocr_data=oci.ai_document.models.AnalyzeDocumentResult(
document_metadata=oci.ai_document.models.DocumentMetadata(
page_count=161,
mime_type="EXAMPLE-mimeType-Value"),
pages=[
oci.ai_document.models.Page(
page_number=769,
dimensions=oci.ai_document.models.Dimensions(
width=6920.53,
height=3775.981,
unit="INCH"),
detected_document_types=[
oci.ai_document.models.DetectedDocumentType(
document_type="EXAMPLE-documentType-Value",
confidence=0.32475168)],
detected_languages=[
oci.ai_document.models.DetectedLanguage(
language="EXAMPLE-language-Value",
confidence=0.07101196)],
words=[
oci.ai_document.models.Word(
text="EXAMPLE-text-Value",
confidence=0.1731121,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.9577057,
y=0.44805598)]))],
lines=[
oci.ai_document.models.Line(
text="EXAMPLE-text-Value",
confidence=0.18269998,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.49617696,
y=0.98050463)]),
word_indexes=[22])],
tables=[
oci.ai_document.models.Table(
row_count=454,
column_count=521,
header_rows=[
oci.ai_document.models.TableRow(
cells=[
oci.ai_document.models.Cell(
text="EXAMPLE-text-Value",
row_index=948,
column_index=102,
confidence=0.16822588,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.66899353,
y=0.007975042)]),
word_indexes=[39])])],
confidence=0.9620186,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.44859058,
y=0.92368656)]))],
document_fields=[
oci.ai_document.models.DocumentField(
field_type="LINE_ITEM",
field_value=oci.ai_document.models.ValueTime(
value_type="TIME",
confidence=0.21327114,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.54601544,
y=0.48824334)]),
word_indexes=[486],
value=datetime.strptime(
"2046-10-18T10:18:01.719Z",
"%Y-%m-%dT%H:%M:%S.%fZ"),
text="EXAMPLE-text-Value"),
field_label=oci.ai_document.models.FieldLabel(
name="EXAMPLE-name-Value",
confidence=0.45981306),
field_name=oci.ai_document.models.FieldName(
name="EXAMPLE-name-Value",
confidence=0.49310988,
bounding_polygon=oci.ai_document.models.BoundingPolygon(
normalized_vertices=[
oci.ai_document.models.NormalizedVertex(
x=0.047706723,
y=0.9585324)]),
word_indexes=[268]))])],
detected_document_types=[
oci.ai_document.models.DetectedDocumentType(
document_type="EXAMPLE-documentType-Value",
confidence=0.77669525)],
detected_languages=[
oci.ai_document.models.DetectedLanguage(
language="EXAMPLE-language-Value",
confidence=0.2833863)],
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",
errors=[
oci.ai_document.models.ProcessingError(
code="EXAMPLE-code-Value",
message="EXAMPLE-message-Value")],
searchable_pdf="Eq8wLwIGbjMOKTw1igxs")),
if_match="EXAMPLE-ifMatch-Value",
opc_request_id="HMAHY8KDODQGEQGCXIGN<unique_ID>")
# Get the data from response
print(analyze_document_response.data)