# 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

# 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.DocumentElementsExtractionFeature(
                feature_type="DOCUMENT_ELEMENTS_EXTRACTION",
                model_id="ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value")],
        document=oci.ai_document.models.ObjectStorageDocumentDetails(
            source="OBJECT_STORAGE",
            namespace_name="EXAMPLE-namespaceName-Value",
            bucket_name="EXAMPLE-bucketName-Value",
            object_name="EXAMPLE-objectName-Value",
            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="RECEIPT",
        ocr_data=oci.ai_document.models.AnalyzeDocumentResult(
            document_metadata=oci.ai_document.models.DocumentMetadata(
                page_count=279,
                mime_type="EXAMPLE-mimeType-Value"),
            pages=[
                oci.ai_document.models.Page(
                    page_number=168,
                    dimensions=oci.ai_document.models.Dimensions(
                        width=6506.377,
                        height=1836.6045,
                        unit="INCH"),
                    detected_document_types=[
                        oci.ai_document.models.DetectedDocumentType(
                            document_type="EXAMPLE-documentType-Value",
                            confidence=0.20636326,
                            document_id="ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value")],
                    detected_languages=[
                        oci.ai_document.models.DetectedLanguage(
                            language="EXAMPLE-language-Value",
                            confidence=0.9804424)],
                    words=[
                        oci.ai_document.models.Word(
                            text="EXAMPLE-text-Value",
                            confidence=0.18925643,
                            bounding_polygon=oci.ai_document.models.BoundingPolygon(
                                normalized_vertices=[
                                    oci.ai_document.models.NormalizedVertex(
                                        x=0.7567968,
                                        y=0.16993767)]))],
                    lines=[
                        oci.ai_document.models.Line(
                            text="EXAMPLE-text-Value",
                            confidence=0.2521472,
                            bounding_polygon=oci.ai_document.models.BoundingPolygon(
                                normalized_vertices=[
                                    oci.ai_document.models.NormalizedVertex(
                                        x=0.26323795,
                                        y=0.69503534)]),
                            word_indexes=[796])],
                    tables=[
                        oci.ai_document.models.Table(
                            row_count=337,
                            column_count=386,
                            header_rows=[
                                oci.ai_document.models.TableRow(
                                    cells=[
                                        oci.ai_document.models.Cell(
                                            text="EXAMPLE-text-Value",
                                            row_index=862,
                                            column_index=665,
                                            confidence=0.37774736,
                                            bounding_polygon=oci.ai_document.models.BoundingPolygon(
                                                normalized_vertices=[
                                                    oci.ai_document.models.NormalizedVertex(
                                                        x=0.27124602,
                                                        y=0.08899367)]),
                                            word_indexes=[986])])],
                            confidence=0.5289005,
                            bounding_polygon=oci.ai_document.models.BoundingPolygon(
                                normalized_vertices=[
                                    oci.ai_document.models.NormalizedVertex(
                                        x=0.7253601,
                                        y=0.571634)]))],
                    document_fields=[
                        oci.ai_document.models.DocumentField(
                            field_type="LINE_ITEM_FIELD",
                            field_value=oci.ai_document.models.ValueInteger(
                                value_type="INTEGER",
                                confidence=0.81502527,
                                bounding_polygon=oci.ai_document.models.BoundingPolygon(
                                    normalized_vertices=[
                                        oci.ai_document.models.NormalizedVertex(
                                            x=0.17849636,
                                            y=0.83037513)]),
                                word_indexes=[928],
                                value=363,
                                text="EXAMPLE-text-Value",
                                normalized_value="EXAMPLE-normalizedValue-Value",
                                normalized_confidence=0.44432253),
                            field_label=oci.ai_document.models.FieldLabel(
                                name="EXAMPLE-name-Value",
                                confidence=0.99906224),
                            field_name=oci.ai_document.models.FieldName(
                                name="EXAMPLE-name-Value",
                                confidence=0.12940931,
                                bounding_polygon=oci.ai_document.models.BoundingPolygon(
                                    normalized_vertices=[
                                        oci.ai_document.models.NormalizedVertex(
                                            x=0.6239295,
                                            y=0.31811917)]),
                                word_indexes=[287]))],
                    signatures=[
                        oci.ai_document.models.Signature(
                            confidence=0.053895116,
                            bounding_polygon=oci.ai_document.models.BoundingPolygon(
                                normalized_vertices=[
                                    oci.ai_document.models.NormalizedVertex(
                                        x=0.33834213,
                                        y=0.26724082)]))],
                    bar_codes=[
                        oci.ai_document.models.BarCode(
                            confidence=0.0715785,
                            value="EXAMPLE-value-Value",
                            bounding_polygon=oci.ai_document.models.BoundingPolygon(
                                normalized_vertices=[
                                    oci.ai_document.models.NormalizedVertex(
                                        x=0.45336193,
                                        y=0.13147873)]),
                            code_type="EXAMPLE-codeType-Value")],
                    selection_marks=[
                        oci.ai_document.models.SelectionMark(
                            state="UNSELECTED",
                            confidence=0.6809422,
                            bounding_polygon=oci.ai_document.models.BoundingPolygon(
                                normalized_vertices=[
                                    oci.ai_document.models.NormalizedVertex(
                                        x=0.30912173,
                                        y=0.50898546)]))])],
            detected_document_types=[
                oci.ai_document.models.DetectedDocumentType(
                    document_type="EXAMPLE-documentType-Value",
                    confidence=0.9831584,
                    document_id="ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value")],
            detected_languages=[
                oci.ai_document.models.DetectedLanguage(
                    language="EXAMPLE-language-Value",
                    confidence=0.2196948)],
            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="4m2NfDwbnj1gbg1IxHDZ")),
    if_match="EXAMPLE-ifMatch-Value",
    opc_request_id="MNREAKWJSDFRX2NFLO7N<unique_ID>")

# Get the data from response
print(analyze_document_response.data)