// 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).
import * as aidocument from "oci-aidocument";
import common = require("oci-common");
// 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.
const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();
(async () => {
try {
// Create a service client
const client = new aidocument.AIServiceDocumentClient({ authenticationDetailsProvider: provider });
// Create a request and dependent object(s).
const analyzeDocumentDetails = {
features: [{
featureType: "DOCUMENT_CLASSIFICATION", maxResults: 394,
modelId: "ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value",
tenancyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value"
}
],
document: {
source: "OBJECT_STORAGE", namespaceName: "EXAMPLE-namespaceName-Value",
bucketName: "EXAMPLE-bucketName-Value",
objectName: "EXAMPLE-objectName-Value",
pageRange: ["EXAMPLE--Value" ]
}
,
compartmentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
outputLocation: {
namespaceName: "EXAMPLE-namespaceName-Value",
bucketName: "EXAMPLE-bucketName-Value",
prefix: "EXAMPLE-prefix-Value",
}
,
language: "EXAMPLE-language-Value",
documentType: aidocument.models.DocumentType.Invoice,
ocrData: {
documentMetadata: {
pageCount: 752,
mimeType: "EXAMPLE-mimeType-Value",
}
,
pages: [{
pageNumber: 267,
dimensions: {
width: 8238.592,
height: 9825.451,
unit: aidocument.models.Dimensions.Unit.Inch,
}
,
detectedDocumentTypes: [{
documentType: "EXAMPLE-documentType-Value",
documentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value",
confidence: 0.8732025,
}
],
detectedLanguages: [{
language: "EXAMPLE-language-Value",
confidence: 0.28415382,
}
],
words: [{
text: "EXAMPLE-text-Value",
confidence: 0.5542056,
boundingPolygon: {
normalizedVertices: [{
x: 0.7934123,
y: 0.065181255,
}
],
}
,
}
],
lines: [{
text: "EXAMPLE-text-Value",
confidence: 0.9004876,
boundingPolygon: {
normalizedVertices: [{
x: 0.3107564,
y: 0.26773477,
}
],
}
,
wordIndexes: [805 ],
}
],
tables: [{
rowCount: 150,
columnCount: 87,
headerRows: [{
cells: [{
text: "EXAMPLE-text-Value",
rowIndex: 89,
columnIndex: 526,
confidence: 0.5777981,
boundingPolygon: {
normalizedVertices: [{
x: 0.38006175,
y: 0.18621355,
}
],
}
,
wordIndexes: [523 ],
}
],
}
],
confidence: 0.92836213,
boundingPolygon: {
normalizedVertices: [{
x: 0.9061476,
y: 0.04473734,
}
],
}
,
}
],
documentFields: [{
fieldType: aidocument.models.DocumentField.FieldType.KeyValue,
fieldLabel: {
name: "EXAMPLE-name-Value",
confidence: 0.27984208,
}
,
fieldName: {
name: "EXAMPLE-name-Value",
confidence: 0.9910751,
boundingPolygon: {
normalizedVertices: [{
x: 0.498937,
y: 0.026857853,
}
],
}
,
wordIndexes: [845 ],
}
,
fieldValue: {
valueType: "STRING", value: "EXAMPLE-value-Value",
text: "EXAMPLE-text-Value",
confidence: 0.1708327,
boundingPolygon: {
normalizedVertices: [{
x: 0.124837875,
y: 0.5007388,
}
],
}
,
wordIndexes: [618 ],
normalizedValue: "EXAMPLE-normalizedValue-Value",
normalizedConfidence: 0.0031592846
}
,
}
],
signatures: [{
confidence: 0.47129804,
boundingPolygon: {
normalizedVertices: [{
x: 0.24667645,
y: 0.63676316,
}
],
}
,
}
],
barCodes: [{
confidence: 0.9956515,
value: "EXAMPLE-value-Value",
codeType: "EXAMPLE-codeType-Value",
boundingPolygon: {
normalizedVertices: [{
x: 0.9223069,
y: 0.993917,
}
],
}
,
}
],
selectionMarks: [{
state: aidocument.models.SelectionMark.State.Unselected,
confidence: 0.40522736,
boundingPolygon: {
normalizedVertices: [{
x: 0.12396753,
y: 0.9095807,
}
],
}
,
}
],
}
],
detectedDocumentTypes: [{
documentType: "EXAMPLE-documentType-Value",
documentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value",
confidence: 0.043004274,
}
],
detectedLanguages: [{
language: "EXAMPLE-language-Value",
confidence: 0.89076304,
}
],
documentClassificationModelVersion: "EXAMPLE-documentClassificationModelVersion-Value",
languageClassificationModelVersion: "EXAMPLE-languageClassificationModelVersion-Value",
textExtractionModelVersion: "EXAMPLE-textExtractionModelVersion-Value",
keyValueExtractionModelVersion: "EXAMPLE-keyValueExtractionModelVersion-Value",
tableExtractionModelVersion: "EXAMPLE-tableExtractionModelVersion-Value",
signatureExtractionModelVersion: "EXAMPLE-signatureExtractionModelVersion-Value",
barCodeExtractionModelVersion: "EXAMPLE-barCodeExtractionModelVersion-Value",
errors: [{
code: "EXAMPLE-code-Value",
message: "EXAMPLE-message-Value",
}
],
searchablePdf: "some Byte data",
}
,
}
const analyzeDocumentRequest: aidocument.requests.AnalyzeDocumentRequest = {
analyzeDocumentDetails: analyzeDocumentDetails,
ifMatch: "EXAMPLE-ifMatch-Value",
opcRequestId: "A6LCZEPBUGGCFMOOKLKD<unique_ID>",
};
// Send request to the Client.
const analyzeDocumentResponse = await client.analyzeDocument(analyzeDocumentRequest);
}
catch (error) {
console.log("analyzeDocument Failed with error " + error);
}
})();