// 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{DocumentType: aidocument.DocumentTypeTaxForm,
Features: []aidocument.DocumentFeature{aidocument.DocumentClassificationFeature{MaxResults: common.Int(432),
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{TableExtractionModelVersion: common.String("EXAMPLE-tableExtractionModelVersion-Value"),
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.1139555),
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.30654174),
Language: common.String("EXAMPLE-language-Value")}},
DocumentClassificationModelVersion: common.String("EXAMPLE-documentClassificationModelVersion-Value"),
DocumentMetadata: &aidocument.DocumentMetadata{MimeType: common.String("EXAMPLE-mimeType-Value"),
PageCount: common.Int(250)},
Errors: []aidocument.ProcessingError{aidocument.ProcessingError{Code: common.String("EXAMPLE-code-Value"),
Message: common.String("EXAMPLE-message-Value")}},
LanguageClassificationModelVersion: common.String("EXAMPLE-languageClassificationModelVersion-Value"),
SearchablePdf: []byte("XaB8RVzf2CxmDpgDWu90"),
TextExtractionModelVersion: common.String("EXAMPLE-textExtractionModelVersion-Value"),
BarCodeExtractionModelVersion: common.String("EXAMPLE-barCodeExtractionModelVersion-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{Y: common.Float64(0.22161049),
X: common.Float64(0.522844)}}},
Confidence: common.Float32(0.70080215)}},
BarCodes: []aidocument.BarCode{aidocument.BarCode{CodeType: common.String("EXAMPLE-codeType-Value"),
Confidence: common.Float32(0.6465673),
Value: common.String("EXAMPLE-value-Value"),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.010664761),
Y: common.Float64(0.9139998)}}}}},
PageNumber: common.Int(671),
Dimensions: &aidocument.Dimensions{Height: common.Float64(2690.0708),
Unit: aidocument.DimensionsUnitPixel,
Width: common.Float64(5552.317)},
DocumentFields: []aidocument.DocumentField{aidocument.DocumentField{FieldLabel: &aidocument.FieldLabel{Confidence: common.Float32(0.19787657),
Name: common.String("EXAMPLE-name-Value")},
FieldName: &aidocument.FieldName{WordIndexes: []int{857},
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5740698),
Y: common.Float64(0.24411601)}}},
Confidence: common.Float32(0.9157813),
Name: common.String("EXAMPLE-name-Value")},
FieldType: aidocument.DocumentFieldFieldTypeLineItem,
FieldValue: aidocument.ValueString{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.5848331),
Y: common.Float64(0.17695802)}}},
Confidence: common.Float32(0.01175487),
NormalizedConfidence: common.Float32(0.009460926),
NormalizedValue: common.String("EXAMPLE-normalizedValue-Value"),
Text: common.String("EXAMPLE-text-Value"),
Value: common.String("EXAMPLE-value-Value"),
WordIndexes: []int{980}}}},
Lines: []aidocument.Line{aidocument.Line{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.90874636),
Y: common.Float64(0.54035455)}}},
Confidence: common.Float32(0.9701144),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{965}}},
SelectionMarks: []aidocument.SelectionMark{aidocument.SelectionMark{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.7193721),
Y: common.Float64(0.2366736)}}},
Confidence: common.Float32(0.34026295),
State: aidocument.SelectionMarkStateUnselected}},
Tables: []aidocument.Table{aidocument.Table{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.9644549),
Y: common.Float64(0.97741765)}}},
ColumnCount: common.Int(726),
Confidence: common.Float32(0.9176092),
HeaderRows: []aidocument.TableRow{aidocument.TableRow{Cells: []aidocument.Cell{aidocument.Cell{BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.6972282),
Y: common.Float64(0.97477674)}}},
ColumnIndex: common.Int(590),
Confidence: common.Float32(0.34786588),
RowIndex: common.Int(384),
Text: common.String("EXAMPLE-text-Value"),
WordIndexes: []int{186}}}}},
RowCount: common.Int(24)}},
Words: []aidocument.Word{aidocument.Word{Confidence: common.Float32(0.060491383),
Text: common.String("EXAMPLE-text-Value"),
BoundingPolygon: &aidocument.BoundingPolygon{NormalizedVertices: []aidocument.NormalizedVertex{aidocument.NormalizedVertex{X: common.Float64(0.77086824),
Y: common.Float64(0.65454686)}}}}},
DetectedDocumentTypes: []aidocument.DetectedDocumentType{aidocument.DetectedDocumentType{Confidence: common.Float32(0.7075796),
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.3521831),
Language: common.String("EXAMPLE-language-Value")}}}},
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"),
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"}}},
IfMatch: common.String("EXAMPLE-ifMatch-Value"),
OpcRequestId: common.String("EIVEVNS9UGE5HPRCIGGY<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)
}