// 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).

package main

import (
	"context"
	"fmt"

	"github.com/oracle/oci-go-sdk/v65/aidocument"
	"github.com/oracle/oci-go-sdk/v65/common"
	"github.com/oracle/oci-go-sdk/v65/example/helpers"
)

func ExampleAnalyzeDocument() {
	// Create a default authentication provider that uses the DEFAULT
	// profile in the configuration file.
	// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
	client, err := aidocument.NewAIServiceDocumentClientWithConfigurationProvider(common.DefaultConfigProvider())
	helpers.FatalIfError(err)

	// Create a request and dependent object(s).

	req := aidocument.AnalyzeDocumentRequest{OpcRequestId: common.String("ODFWXII2DTWOJTSBWSYT<unique_ID>"),
		AnalyzeDocumentDetails: aidocument.AnalyzeDocumentDetails{CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
			Document: aidocument.ObjectStorageDocumentDetails{BucketName: common.String("EXAMPLE-bucketName-Value"),
				NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
				ObjectName:    common.String("EXAMPLE-objectName-Value")},
			DocumentType: aidocument.DocumentTypeReceipt,
			Features: []aidocument.DocumentFeature{aidocument.DocumentClassificationFeature{MaxResults: common.Int(219),
				ModelId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value")}},
			Language: common.String("EXAMPLE-language-Value"),
			OcrData: &aidocument.AnalyzeDocumentResult{DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.8701299),
				Language: common.String("EXAMPLE-language-Value")}},
				DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
				Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
					Message: common.String("EXAMPLE-message-Value")}},
				TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
				TextExtractionModelVersion:  common.String("EXAMPLE-textExtractionModelVersion-Value"),
				DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.10122973),
					DocumentType: common.String("EXAMPLE-documentType-Value")}},
				DocumentMetadata: &aidocument.DocumentMetadata{PageCount: common.Int(127),
					MimeType: common.String("EXAMPLE-mimeType-Value")},
				KeyValueExtractionModelVersion:     common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
				LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
				Pages: []aidocument.Page{aidocument.Page{Lines: []aidocument.Line{aidocument.Line{Text: common.String("EXAMPLE-text-Value"),
					WordIndexes: []int{985},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.27604598),
						Y: common.Float64(0.7553825)}}},
					Confidence: common.Float32(0.06090498)}},
					PageNumber: common.Int(382),
					Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.422437),
						Y: common.Float64(0.07103139)}}},
						ColumnCount: common.Int(674),
						Confidence:  common.Float32(0.70764166),
						HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{Text: common.String("EXAMPLE-text-Value"),
							WordIndexes: []int{480},
							BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.90076697),
								Y: common.Float64(0.008078635)}}},
							ColumnIndex: common.Int(764),
							Confidence:  common.Float32(0.66497254),
							RowIndex:    common.Int(491)}}}},
						RowCount: common.Int(968)}},
					Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.9067858),
						Y: common.Float64(0.5129727)}}},
						Confidence: common.Float32(0.10087681),
						Text:       common.String("EXAMPLE-text-Value")}},
					DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{DocumentType: common.String("EXAMPLE-documentType-Value"),
						Confidence: common.Float32(0.34524328)}},
					DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.1531815),
						Language: common.String("EXAMPLE-language-Value")}},
					Dimensions: &aidocument.Dimensions{Height: common.Float64(1671.9388),
						Unit:  aidocument.DimensionsUnitPixel,
						Width: common.Float64(6289.694)},
					DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.89359957),
						Name: common.String("EXAMPLE-name-Value")},
						FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.62358516),
							Y: common.Float64(0.4987979)}}},
							Confidence:  common.Float32(0.46148318),
							Name:        common.String("EXAMPLE-name-Value"),
							WordIndexes: []int{99}},
						FieldType: aidocument.DocumentFieldFieldTypeLineItem,
						FieldValue: aidocument.ValueInteger{Value: common.Int(95),
							WordIndexes: []int{591},
							BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.9670934),
								Y: common.Float64(0.187617)}}},
							Confidence: common.Float32(0.019985616),
							Text:       common.String("EXAMPLE-text-Value")}}}}},
				SearchablePdf: []byte("FagQEFQruMpCExvMZiBV")},
			OutputLocation: &aidocument.OutputLocation{Prefix: common.String("EXAMPLE-prefix-Value"),
				BucketName:    common.String("EXAMPLE-bucketName-Value"),
				NamespaceName: common.String("EXAMPLE-namespaceName-Value")}},
		IfMatch: common.String("EXAMPLE-ifMatch-Value")}

	// Send the request using the service client
	resp, err := client.AnalyzeDocument(context.Background(), req)
	helpers.FatalIfError(err)

	// Retrieve value from the response.
	fmt.Println(resp)
}