// 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.InlineDocumentDetails{Data: []byte("Wfg62G7WiCaIQhwA6w4X"),
PageRange: []string{"EXAMPLE--Value"}},
DocumentType: aidocument.DocumentTypeBankStatement,
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(923)}},
Language: common.String("EXAMPLE-language-Value"),
OcrData: &aidocument.AnalyzeDocumentResult{TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{DocumentType: common.String("EXAMPLE-documentType-Value"),
Confidence: common.Float32(0.6861939),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value")}},
DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(118)},
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
SearchablePdf: []byte("rcIGGYZ2UIxocnaJtpna"),
SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.373937),
Language: common.String("EXAMPLE-language-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"),
Pages: []aidocument.Page{aidocument.Page{DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.6473416),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.20296979),
Y: common.Float64(0.8738332)}}},
Confidence: common.Float32(0.5139747),
Name: common.String("EXAMPLE-name-Value"),
WordIndexes: []int{378}},
FieldType: aidocument.DocumentFieldFieldTypeLineItem,
FieldValue: aidocument.ValueInteger{WordIndexes: []int{896},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.74553514),
X: common.Float64(0.98272616)}}},
Confidence: common.Float32(0.13295424),
NormalizedConfidence: common.Float32(0.65597695),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
Text: common.String("EXAMPLE-text-Value"),
Value: common.Int(381)}}},
PageNumber: common.Int(581),
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.64210576),
Y: common.Float64(0.42029124)}}},
Confidence: common.Float32(0.053613544),
State: aidocument.SelectionMarkStateUnselected}},
Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.45815998),
Y: common.Float64(0.10512388)}}},
ColumnCount: common.Int(417),
Confidence: common.Float32(0.6479659),
HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.53725183),
Y: common.Float64(0.37072593)}}},
ColumnIndex: common.Int(258),
Confidence: common.Float32(0.9039003),
RowIndex: common.Int(677),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{777}}}}},
RowCount: common.Int(674)}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.8341445),
X: common.Float64(0.6711063)}}},
CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.92153996),
Value: common.String("EXAMPLE-value-Value")}},
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.22161049),
Language: common.String("EXAMPLE-language-Value")}},
Dimensions: &aidocument.Dimensions{Height: common.Float64(5356.5615),
Unit: aidocument.DimensionsUnitInch,
Width: common.Float64(2441.1602)},
Lines: []aidocument.Line{aidocument.Line{Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{717},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.7193721),
X: common.Float64(0.34026295)}}},
Confidence: common.Float32(0.30815923)}},
Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.8568211),
Y: common.Float64(0.38600522)}}},
Confidence: common.Float32(0.71267736)}},
Words: []aidocument.Word{aidocument.Word{Confidence: common.Float32(0.6465673),
Text: common.String("EXAMPLE-text-Value"),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.010664761),
Y: common.Float64(0.9139998)}}}}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.522844),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value")}}}}},
OutputLocation: &aidocument.OutputLocation{BucketName: common.String("EXAMPLE-bucketName-Value"),
NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
Prefix: common.String("EXAMPLE-prefix-Value")}},
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("KSHEJ3CA7M6RJJIAET2L<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)
}