// 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{BucketName: common.String("EXAMPLE-bucketName-Value"),
NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
ObjectName: common.String("EXAMPLE-objectName-Value"),
PageRange: []string{"EXAMPLE--Value"}},
DocumentType: aidocument.DocumentTypeCheck,
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(480)}},
Language: common.String("EXAMPLE-language-Value"),
OcrData: &aidocument.AnalyzeDocumentResult{DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.26406038),
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.27803117),
Language: common.String("EXAMPLE-language-Value")}},
DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(406)},
KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
Pages: []aidocument.Page{aidocument.Page{Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.46551925),
Y: common.Float64(0.5997962)}}},
Confidence: common.Float32(0.50883406),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{17}}},
PageNumber: common.Int(392),
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5484517),
Y: common.Float64(0.42452675)}}},
Confidence: common.Float32(0.24466419),
State: aidocument.SelectionMarkStateUnselected}},
Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.073206306),
Y: common.Float64(0.1410889)}}},
Confidence: common.Float32(0.58054036)}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.203111),
Value: common.String("EXAMPLE-value-Value"),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.910746),
Y: common.Float64(0.57584155)}}}}},
Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6347457),
Y: common.Float64(0.34505373)}}},
ColumnCount: common.Int(484),
Confidence: common.Float32(0.89703614),
HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{224},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6485463),
Y: common.Float64(0.2361151)}}},
ColumnIndex: common.Int(680),
Confidence: common.Float32(0.6801139),
RowIndex: common.Int(681)}}}},
RowCount: common.Int(515)}},
Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5292445),
Y: common.Float64(0.64636666)}}},
Confidence: common.Float32(0.6383161),
Text: common.String("EXAMPLE-text-Value")}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.292742),
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.79464877),
Language: common.String("EXAMPLE-language-Value")}},
Dimensions: &aidocument.Dimensions{Height: common.Float64(448.99225),
Unit: aidocument.DimensionsUnitPixel,
Width: common.Float64(5850.377)},
DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.45684963),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.68222594),
Y: common.Float64(0.34030187)}}},
Confidence: common.Float32(0.54962003),
Name: common.String("EXAMPLE-name-Value"),
WordIndexes: []int{400}},
FieldType: aidocument.DocumentFieldFieldTypeLineItem,
FieldValue: aidocument.ValueDate{Confidence: common.Float32(0.18187869),
NormalizedConfidence: common.Float32(0.3139165),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
Text: common.String("EXAMPLE-text-Value"),
Value: &common.SDKTime{Time: time.Now()},
WordIndexes: []int{398},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.7356378),
Y: common.Float64(0.04115498)}}}}}}}},
SearchablePdf: []byte("RCKfR4PbLq2uMbnU7mSw"),
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Message: common.String("EXAMPLE-message-Value"),
Code: common.String("EXAMPLE-code-Value")}},
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-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("ZSLNH4908UPQFCDVP1KJ<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)
}