// 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{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("Olbwd9QxikCjy3B5kA4k"),
PageRange: []string{"EXAMPLE--Value"}},
DocumentType: aidocument.DocumentTypeBankStatement,
Features: []aidocument.DocumentFeature{aidocument.DocumentKeyValueExtractionFeature{ModelId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value"),
TenancyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value")}},
Language: common.String("EXAMPLE-language-Value"),
OcrData: &aidocument.AnalyzeDocumentResult{LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
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.8270148)}},
DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(942)},
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{BarCodes: []aidocument.BarCode{aidocument.BarCode{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.624647),
Y: common.Float64(0.15397185)}}},
CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.6111661),
Value: common.String("EXAMPLE-value-Value")}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.22789025),
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.123053014),
Language: common.String("EXAMPLE-language-Value")}},
PageNumber: common.Int(785),
Signatures: []aidocument.Signature{aidocument.Signature{Confidence: common.Float32(0.31355226),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.40833575),
Y: common.Float64(0.85365367)}}}}},
Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.22027153),
Y: common.Float64(0.73627967)}}},
ColumnCount: common.Int(744),
Confidence: common.Float32(0.57626987),
HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{379},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6240876),
Y: common.Float64(0.8025609)}}},
ColumnIndex: common.Int(723),
Confidence: common.Float32(0.7672877),
RowIndex: common.Int(333)}}}},
RowCount: common.Int(712)}},
Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.17528802),
Y: common.Float64(0.20019275)}}},
Confidence: common.Float32(0.5273331),
Text: common.String("EXAMPLE-text-Value")}},
Dimensions: &aidocument.Dimensions{Unit: aidocument.DimensionsUnitInch,
Width: common.Float64(7726.113),
Height: common.Float64(5598.2563)},
DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.75548834),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{WordIndexes: []int{247},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.56492835),
X: common.Float64(0.86754537)}}},
Confidence: common.Float32(0.8991313),
Name: common.String("EXAMPLE-name-Value")},
FieldType: aidocument.DocumentFieldFieldTypeLineItem,
FieldValue: aidocument.ValueTime{Text: common.String("EXAMPLE-text-Value"),
Value: &common.SDKTime{Time: time.Now()},
WordIndexes: []int{361},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.2953549),
Y: common.Float64(0.85166204)}}},
Confidence: common.Float32(0.45873475),
NormalizedConfidence: common.Float32(0.55912024),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value")}}},
Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.1850158),
Y: common.Float64(0.7565052)}}},
Confidence: common.Float32(0.49845845),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{426}}},
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.64515597),
Y: common.Float64(0.8809599)}}},
Confidence: common.Float32(0.5396766),
State: aidocument.SelectionMarkStateSelected}}}},
SearchablePdf: []byte("pR13mmDEB4jrCarxvGGF"),
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Language: common.String("EXAMPLE-language-Value"),
Confidence: common.Float32(0.3439402)}}}},
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("IKNSCX3KPFVPZD6JLYZD<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)
}