// 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{Document: aidocument.InlineDocumentDetails{Data: []byte("2AERF1ixOsJw77lGhinb"),
PageRange: []string{"EXAMPLE--Value"}},
DocumentType: aidocument.DocumentTypeResume,
Features: []aidocument.DocumentFeature{aidocument.DocumentElementsExtractionFeature{ModelId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value")}},
Language: common.String("EXAMPLE-language-Value"),
OcrData: &aidocument.AnalyzeDocumentResult{TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-Value"),
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.30109823),
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.5777981),
Language: common.String("EXAMPLE-language-Value")}},
DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(124)},
Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
Message: common.String("EXAMPLE-message-Value")}},
KeyValueExtractionModelVersion: common.String("EXAMPLE-keyValueExtractionModelVersion-Value"),
SearchablePdf: []byte("pz7uXmI5PgMweXVtf3EF"),
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
Pages: []aidocument.Page{aidocument.Page{DetectedLanguages: []aidocument.DetectedLanguage{aidocument.DetectedLanguage{Confidence: common.Float32(0.79856807),
Language: common.String("EXAMPLE-language-Value")}},
Dimensions: &aidocument.Dimensions{Height: common.Float64(9558.178),
Unit: aidocument.DimensionsUnitPixel,
Width: common.Float64(8103.944)},
DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.8238592),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.73039603),
Y: common.Float64(0.8732025)}}},
Confidence: common.Float32(0.9825451),
Name: common.String("EXAMPLE-name-Value"),
WordIndexes: []int{696}},
FieldType: aidocument.DocumentFieldFieldTypeLineItem,
FieldValue: aidocument.ValueArray{Confidence: common.Float32(0.9056299),
NormalizedConfidence: common.Float32(0.8500111),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{109},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.43781954),
X: common.Float64(0.33312047)}}}}}},
PageNumber: common.Int(731),
Signatures: []aidocument.Signature{aidocument.Signature{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{Y: common.Float64(0.065181255),
X: common.Float64(0.7934123)}}},
Confidence: common.Float32(0.5542056)}},
Tables: []aidocument.Table{aidocument.Table{ColumnCount: common.Int(51),
Confidence: common.Float32(0.02838248),
HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{ColumnIndex: common.Int(380),
Confidence: common.Float32(0.9049306),
RowIndex: common.Int(547),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{928},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.23141193),
Y: common.Float64(0.53373486)}}}}}}},
RowCount: common.Int(176),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5173472),
Y: common.Float64(0.19143075)}}}}},
Words: []aidocument.Word{aidocument.Word{Confidence: common.Float32(0.82585025),
Text: common.String("EXAMPLE-text-Value"),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.893446),
Y: common.Float64(0.25737917)}}}}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{Value: common.String("EXAMPLE-value-Value"),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.3107564),
Y: common.Float64(0.26773477)}}},
CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.9004876)}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.678442),
DocumentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value"),
DocumentType: common.String("EXAMPLE-documentType-Value")}},
Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.018351376),
Y: common.Float64(0.9414628)}}},
Confidence: common.Float32(0.7323424),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{315}}},
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.43582314),
Y: common.Float64(0.23760694)}}},
Confidence: common.Float32(0.26290357),
State: aidocument.SelectionMarkStateUnselected}}}},
SignatureExtractionModelVersion: common.String("EXAMPLE-signatureExtractionModelVersion-Value")},
OutputLocation: &aidocument.OutputLocation{BucketName: common.String("EXAMPLE-bucketName-Value"),
NamespaceName: common.String("EXAMPLE-namespaceName-Value"),
Prefix: common.String("EXAMPLE-prefix-Value")},
CompartmentId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value")},
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("DHKF7FVLRN0P3DNDWQEG<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)
}