// 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{OpcRequestId: common.String("MENYARCKE5QQAS5CBUJT<unique_ID>"),
AnalyzeDocumentDetails: aidocument.AnalyzeDocumentDetails{CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value"),
Document: aidocument.InlineDocumentDetails{Data: []byte("t2L4aJNKBNW8O17Yjm7p"),
PageRange: []string{"EXAMPLE--Value"}},
DocumentType: aidocument.DocumentTypeOthers,
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{DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(95)},
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
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.6526648),
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.2801888),
Language: common.String("EXAMPLE-language-Value")}},
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
SearchablePdf: []byte("TISGGLhouKwVMBScF1HZ"),
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{Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.22608817),
Y: common.Float64(0.54958296)}}},
Confidence: common.Float32(0.047626674)}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.2196948),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value")}},
Dimensions: &aidocument.Dimensions{Height: common.Float64(5089.8545),
Unit: aidocument.DimensionsUnitInch,
Width: common.Float64(3091.2173)},
PageNumber: common.Int(975),
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.42870533),
Y: common.Float64(0.7627087)}}},
Confidence: common.Float32(0.58318764),
State: aidocument.SelectionMarkStateSelected}},
Tables: []aidocument.Table{aidocument.Table{Confidence: common.Float32(0.1628589),
HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{126},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.75615996),
X: common.Float64(0.18282986)}}},
ColumnIndex: common.Int(144),
Confidence: common.Float32(0.52031004),
RowIndex: common.Int(613)}}}},
RowCount: common.Int(189),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.3749888),
Y: common.Float64(0.6714471)}}},
ColumnCount: common.Int(95)}},
Words: []aidocument.Word{aidocument.Word{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.15680474),
Y: common.Float64(0.1301319)}}},
Confidence: common.Float32(0.9347299),
Text: common.String("EXAMPLE-text-Value")}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5304132),
Y: common.Float64(0.14795685)}}},
CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.2621385),
Value: common.String("EXAMPLE-value-Value")}},
DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.92122245),
Language: common.String("EXAMPLE-language-Value")}},
DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldType: aidocument.DocumentFieldFieldTypeLineItemGroup,
FieldValue: aidocument.ValueString{NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
Text: common.String("EXAMPLE-text-Value"),
Value: common.String("EXAMPLE-value-Value"),
WordIndexes: []int{20},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.7039072),
Y: common.Float64(0.40504313)}}},
Confidence: common.Float32(0.2802983),
NormalizedConfidence: common.Float32(0.35237968)},
FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.15211171),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.35199928),
Y: common.Float64(0.7652765)}}},
Confidence: common.Float32(0.6706607),
Name: common.String("EXAMPLE-name-Value"),
WordIndexes: []int{179}}}},
Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6429207),
Y: common.Float64(0.06972265)}}},
Confidence: common.Float32(0.1316011),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{745}}}}}},
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")}
// 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)
}