// 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: "KEY_VALUE_EXTRACTION", modelId: "ocid1.test.oc1..<unique_ID>EXAMPLE-modelId-Value",
tenancyId: "ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value"
}
],
document: {
source: "INLINE", data: "some Byte data",
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.Passport,
ocrData: {
documentMetadata: {
pageCount: 242,
mimeType: "EXAMPLE-mimeType-Value",
}
,
pages: [{
pageNumber: 456,
dimensions: {
width: 5384.74,
height: 4959.847,
unit: aidocument.models.Dimensions.Unit.Inch,
}
,
detectedDocumentTypes: [{
documentType: "EXAMPLE-documentType-Value",
documentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value",
confidence: 0.2476762,
}
],
detectedLanguages: [{
language: "EXAMPLE-language-Value",
confidence: 0.9435228,
}
],
words: [{
text: "EXAMPLE-text-Value",
confidence: 0.91702473,
boundingPolygon: {
normalizedVertices: [{
x: 0.9935627,
y: 0.16390628,
}
],
}
,
}
],
lines: [{
text: "EXAMPLE-text-Value",
confidence: 0.06763345,
boundingPolygon: {
normalizedVertices: [{
x: 0.63630563,
y: 0.6410271,
}
],
}
,
wordIndexes: [126 ],
}
],
tables: [{
rowCount: 629,
columnCount: 602,
headerRows: [{
cells: [{
text: "EXAMPLE-text-Value",
rowIndex: 128,
columnIndex: 688,
confidence: 0.15351987,
boundingPolygon: {
normalizedVertices: [{
x: 0.90631664,
y: 0.34574497,
}
],
}
,
wordIndexes: [757 ],
}
],
}
],
confidence: 0.8217945,
boundingPolygon: {
normalizedVertices: [{
x: 0.91816366,
y: 0.9762113,
}
],
}
,
}
],
documentFields: [{
fieldType: aidocument.models.DocumentField.FieldType.KeyValue,
fieldLabel: {
name: "EXAMPLE-name-Value",
confidence: 0.1622389,
}
,
fieldName: {
name: "EXAMPLE-name-Value",
confidence: 0.33730292,
boundingPolygon: {
normalizedVertices: [{
x: 0.5552317,
y: 0.2690071,
}
],
}
,
wordIndexes: [106 ],
}
,
fieldValue: {
valueType: "STRING", value: "EXAMPLE-value-Value",
text: "EXAMPLE-text-Value",
confidence: 0.5518287,
boundingPolygon: {
normalizedVertices: [{
x: 0.41557562,
y: 0.30213982,
}
],
}
,
wordIndexes: [591 ],
normalizedValue: "EXAMPLE-normalizedValue-Value",
normalizedConfidence: 0.025857389
}
,
}
],
signatures: [{
confidence: 0.7075796,
boundingPolygon: {
normalizedVertices: [{
x: 0.3521831,
y: 0.060491383,
}
],
}
,
}
],
barCodes: [{
confidence: 0.77086824,
value: "EXAMPLE-value-Value",
codeType: "EXAMPLE-codeType-Value",
boundingPolygon: {
normalizedVertices: [{
x: 0.65454686,
y: 0.9701144,
}
],
}
,
}
],
selectionMarks: [{
state: aidocument.models.SelectionMark.State.Selected,
confidence: 0.54035455,
boundingPolygon: {
normalizedVertices: [{
x: 0.8811885,
y: 0.56706506,
}
],
}
,
}
],
}
],
detectedDocumentTypes: [{
documentType: "EXAMPLE-documentType-Value",
documentId: "ocid1.test.oc1..<unique_ID>EXAMPLE-documentId-Value",
confidence: 0.16307533,
}
],
detectedLanguages: [{
language: "EXAMPLE-language-Value",
confidence: 0.1931243,
}
],
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: "LBGV6KJQUDQVXAB8RVZF<unique_ID>",
};
// Send request to the Client.
const analyzeDocumentResponse = await client.analyzeDocument(analyzeDocumentRequest);
}
catch (error) {
console.log("analyzeDocument Failed with error " + error);
}
})();