// 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.InlineDocumentDetails{PageRange: []string{"EXAMPLE--Value"},
Data: []byte("EFDhkF7FVLrn0P3dNDWQ")},
DocumentType: aidocument.DocumentTypeInvoice,
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(807)}},
Language: common.String("EXAMPLE-language-Value"),
OcrData: &aidocument.AnalyzeDocumentResult{TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.6227809),
Language: common.String("EXAMPLE-language-Value")}},
DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(247)},
Pages: []aidocument.Page{aidocument.Page{DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.22384995),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.09781945),
Y: common.Float64(0.957189)}}},
Confidence: common.Float32(0.83190036),
Name: common.String("EXAMPLE-name-Value"),
WordIndexes: []int{451}},
FieldType: aidocument.DocumentFieldFieldTypeLineItem,
FieldValue: aidocument.ValueDate{WordIndexes: []int{493},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.28537005),
Y: common.Float64(0.13433492)}}},
Confidence: common.Float32(0.13186938),
NormalizedConfidence: common.Float32(0.039599776),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
Text: common.String("EXAMPLE-text-Value"),
Value: &common.SDKTime{Time: time.Now()}}}},
PageNumber: common.Int(378),
Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.2891245),
Y: common.Float64(0.6557804)}}},
ColumnCount: common.Int(69),
Confidence: common.Float32(0.6217948),
HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{WordIndexes: []int{158},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.24389625),
Y: common.Float64(0.42424518)}}},
ColumnIndex: common.Int(449),
Confidence: common.Float32(0.7829652),
RowIndex: common.Int(360),
Text: common.String("EXAMPLE-text-Value")}}}},
RowCount: common.Int(576)}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{Value: common.String("EXAMPLE-value-Value"),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.06723642),
Y: common.Float64(0.69975394)}}},
CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.1739394)}},
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.50798035),
Language: common.String("EXAMPLE-language-Value")}},
Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.17857558),
Y: common.Float64(0.025345564)}}},
Confidence: common.Float32(0.91182446),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{691}}},
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6068976),
Y: common.Float64(0.18583578)}}},
Confidence: common.Float32(0.31349844),
State: aidocument.SelectionMarkStateUnselected}},
Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.8391304),
Y: common.Float64(0.017129779)}}},
Confidence: common.Float32(0.18885899)}},
Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.6069568),
X: common.Float64(0.6181075)}}},
Confidence: common.Float32(0.33965427),
Text: common.String("EXAMPLE-text-Value")}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.28381163),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value")}},
Dimensions: &aidocument.Dimensions{Height: common.Float64(2719.1626),
Unit: aidocument.DimensionsUnitInch,
Width: common.Float64(8334.325)}}},
SearchablePdf: []byte("Mx7ndHFNz16ohtwt8Rnj"),
SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value"),
TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.048840165),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value")}},
Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
Message: common.String("EXAMPLE-message-Value")}},
KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value")},
OutputLocation: &aidocument.OutputLocation{NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
Prefix: common.String("EXAMPLE-prefix-Value"),
BucketName: common.String("EXAMPLE-bucketName-Value")}},
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("LIUBHCFWMWUUUQX42BD8<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)
}