// 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{CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
Document: aidocument.ObjectStorageDocumentDetails{PageRange: []string{"EXAMPLE--Value"},
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{ModelId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value"),
TenancyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value"),
MaxResults: common.Int(88)}},
Language: common.String("EXAMPLE-language-Value"),
OcrData: &aidocument.AnalyzeDocumentResult{DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(251)},
KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
Pages: []aidocument.Page{aidocument.Page{Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.8732025),
Y: common.Float64(0.28415382)}}},
Confidence: common.Float32(0.73039603)}},
Tables: []aidocument.Table{aidocument.Table{HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.9414628),
Y: common.Float64(0.40045255)}}},
ColumnIndex: common.Int(483),
Confidence: common.Float32(0.018351376),
RowIndex: common.Int(686),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{176}}}}},
RowCount: common.Int(914),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.14713478),
Y: common.Float64(0.81087387)}}},
ColumnCount: common.Int(800),
Confidence: common.Float32(0.8541965)}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value"),
Confidence: common.Float32(0.105644405)}},
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.36052614),
Language: common.String("EXAMPLE-language-Value")}},
DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.43781954),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.8500111),
Y: common.Float64(0.8238592)}}},
Confidence: common.Float32(0.91673434),
Name: common.String("EXAMPLE-name-Value"),
WordIndexes: []int{505}},
FieldType: aidocument.DocumentFieldFieldTypeKeyValue,
FieldValue: aidocument.ValueDate{Text: common.String("EXAMPLE-text-Value"),
Value: &common.SDKTime{Time: time.Now()},
WordIndexes: []int{702},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.15109724),
Y: common.Float64(0.02838248)}}},
Confidence: common.Float32(0.53373486),
NormalizedConfidence: common.Float32(0.33312047),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value")}}},
Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.678442),
X: common.Float64(0.41673928)}}},
Confidence: common.Float32(0.95581776),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{964}}},
PageNumber: common.Int(798),
Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5641705),
Y: common.Float64(0.8103944)}}},
Confidence: common.Float32(0.08935666),
Text: common.String("EXAMPLE-text-Value")}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.7934123),
Y: common.Float64(0.065181255)}}},
CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.5542056),
Value: common.String("EXAMPLE-value-Value")}},
Dimensions: &aidocument.Dimensions{Height: common.Float64(4675.816),
Unit: aidocument.DimensionsUnitPixel,
Width: common.Float64(2596.9463)},
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.26773477),
Y: common.Float64(0.1402086)}}},
Confidence: common.Float32(0.3107564),
State: aidocument.SelectionMarkStateSelected}}}},
SearchablePdf: []byte("dimpz7uXmI5PgMweXVtf"),
SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.26290357),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value")}},
Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Message: common.String("EXAMPLE-message-Value"),
Code: common.String("EXAMPLE-code-Value")}},
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.43582314),
Language: common.String("EXAMPLE-language-Value")}}},
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"),
OpcRequestId: common.String("3EFDHKF7FVLRN0P3DNDW<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)
}