// 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{OutputLocation: &aidocument.OutputLocation{Prefix: common.String("EXAMPLE-prefix-Value"),
BucketName: common.String("EXAMPLE-bucketName-Value"),
NamespaceName: common.String("EXAMPLE-namespaceName-Value")},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
Document: aidocument.InlineDocumentDetails{Data: []byte("96hFcsUazIdSy20dQs4h"),
PageRange: []string{"EXAMPLE--Value"}},
DocumentType: aidocument.DocumentTypeInvoice,
Features: []aidocument.DocumentFeature{aidocument.DocumentTableExtractionFeature{ModelId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value")}},
Language: common.String("EXAMPLE-language-Value"),
OcrData: &aidocument.AnalyzeDocumentResult{BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.33161813),
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.025857389),
Language: common.String("EXAMPLE-language-Value")}},
DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(515)},
SearchablePdf: []byte("DvP1KJsn8vtSWfg62G7W"),
TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Message: common.String("EXAMPLE-message-Value"),
Code: common.String("EXAMPLE-code-Value")}},
KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
Pages: []aidocument.Page{aidocument.Page{Dimensions: &aidocument.Dimensions{Height: common.Float64(2273.649),
Unit: aidocument.DimensionsUnitInch,
Width: common.Float64(3403.0188)},
DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.16208017),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{WordIndexes: []int{262},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.15351987),
X: common.Float64(0.8479858)}}},
Confidence: common.Float32(0.46701968),
Name: common.String("EXAMPLE-name-Value")},
FieldType: aidocument.DocumentFieldFieldTypeKeyValue,
FieldValue: aidocument.ValueInteger{WordIndexes: []int{313},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.06763345),
Y: common.Float64(0.63630563)}}},
Confidence: common.Float32(0.16390628),
NormalizedConfidence: common.Float32(0.56479573),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
Text: common.String("EXAMPLE-text-Value"),
Value: common.Int(126)}}},
PageNumber: common.Int(714),
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.30213982),
X: common.Float64(0.41557562)}}},
Confidence: common.Float32(0.5518287),
State: aidocument.SelectionMarkStateSelected}},
Tables: []aidocument.Table{aidocument.Table{HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{WordIndexes: []int{136},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.98944896),
Y: common.Float64(0.538474)}}},
ColumnIndex: common.Int(654),
Confidence: common.Float32(0.24242514),
RowIndex: common.Int(201),
Text: common.String("EXAMPLE-text-Value")}}}},
RowCount: common.Int(394),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.2476762),
Y: common.Float64(0.9435228)}}},
ColumnCount: common.Int(452),
Confidence: common.Float32(0.56144947)}},
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.1410889),
Language: common.String("EXAMPLE-language-Value")}},
Lines: []aidocument.Line{aidocument.Line{Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{353},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.24466419),
Y: common.Float64(0.5484517)}}},
Confidence: common.Float32(0.2771057)}},
Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.72975814),
Y: common.Float64(0.8217945)}}},
Confidence: common.Float32(0.34574497)}},
Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.910746),
Y: common.Float64(0.57584155)}}},
Confidence: common.Float32(0.203111),
Text: common.String("EXAMPLE-text-Value")}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.9762113),
Y: common.Float64(0.7631093)}}},
CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.91816366),
Value: common.String("EXAMPLE-value-Value")}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.073206306),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value")}}}},
SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value")}},
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("ICAIQHWA6W4XZFV8LLBG<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)
}