// 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"
"time"
"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{BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.7731043),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value")}},
Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
Message: common.String("EXAMPLE-message-Value")}},
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
SearchablePdf: []byte("zNah6vDVlcEVr5H6K4fy"),
SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.54440093),
Language: common.String("EXAMPLE-language-Value")}},
DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
DocumentMetadata: &aidocument.DocumentMetadata{PageCount: common.Int(807),
MimeType: common.String("EXAMPLE-mimeType-Value")},
KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
Pages: []aidocument.Page{aidocument.Page{DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.7190623),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value")}},
Lines: []aidocument.Line{aidocument.Line{WordIndexes: []int{886},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.41888177),
Y: common.Float64(0.14207178)}}},
Confidence: common.Float32(0.7887801),
Text: common.String("EXAMPLE-text-Value")}},
PageNumber: common.Int(544),
Tables: []aidocument.Table{aidocument.Table{HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{ColumnIndex: common.Int(746),
Confidence: common.Float32(0.22047222),
RowIndex: common.Int(801),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{743},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.7682858),
Y: common.Float64(0.5438604)}}}}}}},
RowCount: common.Int(626),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6554321),
Y: common.Float64(0.6725511)}}},
ColumnCount: common.Int(237),
Confidence: common.Float32(0.43211836)}},
Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.11705977),
Y: common.Float64(0.15515995)}}},
Confidence: common.Float32(0.071297884),
Text: common.String("EXAMPLE-text-Value")}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{Confidence: common.Float32(0.3701362),
Value: common.String("EXAMPLE-value-Value"),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.62815845),
X: common.Float64(0.121564746)}}},
CodeType: common.String("EXAMPLE-codeType-Value")}},
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.34912992),
Language: common.String("EXAMPLE-language-Value")}},
Dimensions: &aidocument.Dimensions{Height: common.Float64(8147.919),
Unit: aidocument.DimensionsUnitPixel,
Width: common.Float64(6227.809)},
DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.31533659),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.031799674),
Y: common.Float64(0.96926)}}},
Confidence: common.Float32(0.6061945),
Name: common.String("EXAMPLE-name-Value"),
WordIndexes: []int{553}},
FieldType: aidocument.DocumentFieldFieldTypeLineItemGroup,
FieldValue: aidocument.ValueTime{Text: common.String("EXAMPLE-text-Value"),
Value: &common.SDKTime{Time: time.Now()},
WordIndexes: []int{488},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.7572835),
Y: common.Float64(0.3821035)}}},
Confidence: common.Float32(0.23701948),
NormalizedConfidence: common.Float32(0.14955759),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value")}}},
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.18942714),
Y: common.Float64(0.010871828)}}},
Confidence: common.Float32(0.6377586),
State: aidocument.SelectionMarkStateSelected}},
Signatures: []aidocument.Signature{aidocument.Signature{Confidence: common.Float32(0.3057726),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.9044405),
Y: common.Float64(0.7070653)}}}}}}},
TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value")},
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.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.DocumentTypeDriverLicense,
Features: []aidocument.DocumentFeature{aidocument.DocumentTextExtractionFeature{GenerateSearchablePdf: common.Bool(false),
ModelId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value"),
SelectionMarkDetection: common.Bool(false)}},
Language: common.String("EXAMPLE-language-Value")},
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("EHGKR7J096HFCSUAZIDS<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)
}