Post Document Scan¶
Sends an image to the Form Recognizer Automation and returns the extracted information for the specified Machine Learning Pre-trained Model.
It's possible to retrieve the output back in two ways, either in CLOB (character large object) format or in PL/SQL record format.
The method with CLOB output accepts the following parameters:
- response_, out parameter of type CLOB, to which the response will be written.
- image_data_, required parameter of type BLOB to pass the binary image data to the Form Recognizer Automation.
- model_name_, required parameter to specify the Machine Learning Pre-trained Model to be processed.
- response_format_, optional parameter to specify the response format. Possible values are 'JSON' and 'IFS_MESSAGE'. If not specified 'IFS_MESSAGE' will be used as the default format.
- ml_configuration_id_, optional parameter to specify the Configuration ID from Machine Learning Configurations to use. If not specified, the configuration specified in Machine Learning Pre-trained Models for the corresponding Model Name will be used.
DECLARE
response_ CLOB;
image_data_ BLOB;
BEGIN
Ml_Service_Util_API.Post_Document_Scan(
response_ => response_, -- Clob parameter to accept response data.
image_data_ => image_data_, -- Blob parameter to pass the binary image data.
model_name_ => 'CUSTOMER_CONTACT_AUTOMATION', -- Machine Learning Pre-trained Model name.
response_format_ => 'JSON', -- Response format ('JSON' / 'IFS_MESSAGE').
ml_configuration_id_ => 'DEFAULT'); -- Configuration ID to use.
END;
For the above call, the response may look as following. The response may vary depending on the model type and the IFS Machine Learning Service version being used.
{
"Entities": [
{
"Id": "raw_text",
"Value": "JAYTIC VALE Fashion Designer\nKLAMBI\nGedong 8,2 Tampingan street Melbune, AU 10012\n+62 0300 345 678 faddey.vale@klambi.com klambi.com",
"Probability": 1,
"EntityGroupId": "Main"
},
{
"Id": "vendor_address",
"Value": "Gedong 8,2 Tampingan street Melbune, AU 10012",
"Probability": 0.79,
"EntityGroupId": "Main"
},
{
"Id": "vendor_address_recipient",
"Value": "KLAMBI",
"Probability": 0.517,
"EntityGroupId": "Main"
},
{
"Id": "vendor_name",
"Value": "KLAMBI",
"Probability": 0.517,
"EntityGroupId": "Main"
}
],
"EntityGroups": [
"Main"
]
}
Tip: The IFS Message response format ('IFS_MESSAGE') allows using existing methods in Message_SYS package to handle the response which may be simpler to use in the PL/SQL code than 'JSON'.
The method with PL/SQL record output accepts the following parameters:
- response_rec_, out parameter of type record, to which the response will be written.
- image_data_, required parameter of type BLOB to pass the binary image data to the Form Recognizer Automation.
- model_name_, required parameter to specify the Machine Learning Pre-trained Model to be processed.
- ml_configuration_id_, optional parameter to specify the Configuration ID from Machine Learning Configurations to use. If not specified, the configuration specified in Machine Learning Pre-trained Models for the corresponding Model Name will be used.
DECLARE
response_rec_ Ml_SYS.Doc_Scan_Response_Rec;
image_data_ BLOB;
BEGIN
Ml_Service_Util_API.Post_Document_Scan(
response_rec_ => response_rec_, -- Record parameter to accept response data.
image_data_ => image_data_, -- Blob parameter to pass the binary image data.
model_name_ => 'CUSTOMER_CONTACT_AUTOMATION', -- Machine Learning Pre-trained Model name.
response_format_ => 'JSON', -- Response format ('JSON' / 'IFS_MESSAGE').
ml_configuration_id_ => 'DEFAULT'); -- Configuration ID to use.
-- Example of handling response
IF (response_rec_.entities.count > 0) THEN
FOR i_ IN response_rec_.entities.first..response_rec_.entities.last LOOP
Dbms_Output.Put_Line('Id:'||response_rec_.entities(i_).id);
Dbms_Output.Put_Line('Value:'||response_rec_.entities(i_).value);
Dbms_Output.Put_Line('Probability:'||response_rec_.entities(i_).probability);
Dbms_Output.Put_Line('EntityGroupId:'||response_rec_.entities(i_).entity_group_id);
END LOOP;
END IF;
IF (response_rec_.entity_groups.count > 0) THEN
FOR i_ IN response_rec_.entity_groups.first..response_rec_.entity_groups.last LOOP
Dbms_Output.Put_Line('EntityGroupId:'||response_rec_.entity_groups(i_));
END LOOP;
END IF;
END;
The Doc_Scan_Response_Rec response record type has the following format:
TYPE Doc_Scan_Response_Rec IS RECORD (
entities Entity_Arr,
entity_groups Entity_Group_Arr);
The Entity_Arr array type has the following format:
TYPE Entity_Arr IS TABLE OF Entity_Rec;
The Entity_Rec record type has the following format:
TYPE Entity_Rec IS RECORD (
id VARCHAR2(100),
value VARCHAR2(4000),
probability NUMBER,
entity_group_id VARCHAR2(100));
The Entity_Group_Arr array type has the following format:
TYPE Entity_Group_Arr IS TABLE OF VARCHAR2(100);
For more details about the Form Recognizer Automation please see the Machine Learning Service documentation.