// 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{AnalyzeDocumentDetails: aidocument.AnalyzeDocumentDetails{OcrData: &aidocument.AnalyzeDocumentResult{DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.75615996),
		DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
		DocumentType: common.String("EXAMPLE-documentType-Value")}},
		DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
		DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
			PageCount: common.Int(308)},
		LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
		TableExtractionModelVersion:        common.String("EXAMPLE-tableExtractionModelVersion-Value"),
		TextExtractionModelVersion:         common.String("EXAMPLE-textExtractionModelVersion-Value"),
		SignatureExtractionModelVersion:    common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
		BarCodeExtractionModelVersion:      common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
		DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.014942646),
			Language: common.String("EXAMPLE-language-Value")}},
		Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
			Message: common.String("EXAMPLE-message-Value")}},
		KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
		Pages: []aidocument.Page{aidocument.Page{Tables: []aidocument.Table{aidocument.Table{ColumnCount: common.Int(451),
			Confidence: common.Float32(0.33834213),
			HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{ColumnIndex: common.Int(396),
				Confidence:  common.Float32(0.6239295),
				RowIndex:    common.Int(872),
				Text:        common.String("EXAMPLE-text-Value"),
				WordIndexes: []int{984},
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.31811917),
					Y: common.Float64(0.53643167)}}}}}}},
			RowCount: common.Int(363),
			BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.0715785),
				X: common.Float64(0.26724082)}}}}},
			Words: []aidocument.Word{aidocument.Word{Confidence: common.Float32(0.571634),
				Text: common.String("EXAMPLE-text-Value"),
				BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.60623986),
					X: common.Float64(0.74919754)}}}}},
			Dimensions: &aidocument.Dimensions{Unit: aidocument.DimensionsUnitInch,
				Width:  common.Float64(2712.4602),
				Height: common.Float64(889.9367)},
			DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.2196948),
				Name: common.String("EXAMPLE-name-Value")},
				FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.9347299),
					Y: common.Float64(0.15680474)}}},
					Confidence:  common.Float32(0.92122245),
					Name:        common.String("EXAMPLE-name-Value"),
					WordIndexes: []int{173}},
				FieldType: aidocument.DocumentFieldFieldTypeLineItem,
				FieldValue: aidocument.ValueString{Confidence: common.Float32(0.42559123),
					NormalizedConfidence: common.Float32(0.9831584),
					NormalizedValue:      common.String("EXAMPLE-normalizedValue-Value"),
					Text:                 common.String("EXAMPLE-text-Value"),
					Value:                common.String("EXAMPLE-value-Value"),
					WordIndexes:          []int{19},
					BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6809422),
						Y: common.Float64(0.30912173)}}}}}},
			Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.17849636),
				Y: common.Float64(0.83037513)}}},
				Confidence:  common.Float32(0.81502527),
				Text:        common.String("EXAMPLE-text-Value"),
				WordIndexes: []int{928}}},
			Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6429207),
				Y: common.Float64(0.06972265)}}},
				Confidence: common.Float32(0.1316011)}},
			SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.52031004),
				Y: common.Float64(0.18282986)}}},
				Confidence: common.Float32(0.7345532),
				State:      aidocument.SelectionMarkStateUnselected}},
			BarCodes: []aidocument.BarCode{aidocument.BarCode{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.73690766),
				Y: common.Float64(0.017003655)}}},
				CodeType:   common.String("EXAMPLE-codeType-Value"),
				Confidence: common.Float32(0.114546),
				Value:      common.String("EXAMPLE-value-Value")}},
			DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.5289005),
				DocumentId:   common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
				DocumentType: common.String("EXAMPLE-documentType-Value")}},
			DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.7253601),
				Language: common.String("EXAMPLE-language-Value")}},
			PageNumber: common.Int(416)}},
		SearchablePdf: []byte("xHDZmNReakwjsdFRX2nf")},
		OutputLocation: &aidocument.OutputLocation{BucketName: common.String("EXAMPLE-bucketName-Value"),
			NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
			Prefix:        common.String("EXAMPLE-prefix-Value")},
		CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
		Document: aidocument.InlineDocumentDetails{Data: []byte("xocnaJtpnakSheJ3Ca7m"),
			PageRange: []string{"EXAMPLE--Value"}},
		DocumentType: aidocument.DocumentTypeTaxForm,
		Features: []aidocument.DocumentFeature{aidocument.DocumentTextExtractionFeature{SelectionMarkDetection: common.Bool(true),
			GenerateSearchablePdf: common.Bool(false),
			ModelId:               common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value")}},
		Language: common.String("EXAMPLE-language-Value")},
		IfMatch:      common.String("EXAMPLE-ifMatch-Value"),
		OpcRequestId: common.String("LO7N0ATTISGGLHOUKWVM<unique_ID>")}

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