// 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{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"),
PageRange: []string{"EXAMPLE--Value"}},
DocumentType: aidocument.DocumentTypeHealthInsuranceId,
Features: []aidocument.DocumentFeature{aidocument.DocumentLanguageClassificationFeature{MaxResults: common.Int(673)}},
Language: common.String("EXAMPLE-language-Value"),
OcrData: &aidocument.AnalyzeDocumentResult{DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(831)},
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
SearchablePdf: []byte("7sWVcmRCKfR4PbLq2uMb"),
SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-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{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.2361151),
Y: common.Float64(0.6452008)}}},
ColumnCount: common.Int(559),
Confidence: common.Float32(0.6485463),
HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{ColumnIndex: common.Int(515),
Confidence: common.Float32(0.66393584),
RowIndex: common.Int(17),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{511},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.32212847),
Y: common.Float64(0.8598904)}}}}}}},
RowCount: common.Int(980)}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{DocumentType: common.String("EXAMPLE-documentType-Value"),
Confidence: common.Float32(0.5850377),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value")}},
Dimensions: &aidocument.Dimensions{Height: common.Float64(1058.9916),
Unit: aidocument.DimensionsUnitInch,
Width: common.Float64(5512.688)},
DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldValue: aidocument.ValueNumber{Confidence: common.Float32(0.34505373),
NormalizedConfidence: common.Float32(0.04115498),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
Text: common.String("EXAMPLE-text-Value"),
Value: common.Float32(7356.378),
WordIndexes: []int{568},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.4139248),
Y: common.Float64(0.7980748)}}}},
FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.638242),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.49089772),
Y: common.Float64(0.8098093)}}},
Confidence: common.Float32(0.7941087),
Name: common.String("EXAMPLE-name-Value"),
WordIndexes: []int{134}},
FieldType: aidocument.DocumentFieldFieldTypeKeyValue}},
Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.64636666),
X: common.Float64(0.5292445)}}},
Confidence: common.Float32(0.6383161),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{956}}},
PageNumber: common.Int(161),
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{State: aidocument.SelectionMarkStateSelected,
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.1410889),
Y: common.Float64(0.203111)}}},
Confidence: common.Float32(0.073206306)}},
Signatures: []aidocument.Signature{aidocument.Signature{Confidence: common.Float32(0.3139165),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.45684963),
Y: common.Float64(0.54962003)}}}}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.34030187),
Y: common.Float64(0.2273649)}}},
CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.68222594),
Value: common.String("EXAMPLE-value-Value")}},
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.044899225),
Language: common.String("EXAMPLE-language-Value")}},
Words: []aidocument.Word{aidocument.Word{Text: common.String("EXAMPLE-text-Value"),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.79464877),
X: common.Float64(0.292742)}}},
Confidence: common.Float32(0.4822247)}}}},
TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.910746),
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.57584155),
Language: common.String("EXAMPLE-language-Value")}}},
OutputLocation: &aidocument.OutputLocation{NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
Prefix: common.String("EXAMPLE-prefix-Value"),
BucketName: common.String("EXAMPLE-bucketName-Value")}},
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("NU7MSWZSLNH4908UPQFC<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)
}