Post Document Scan¶
Sends an image to the Form Recognizer Automation and returns the extracted information for the specified type.
This is a generic method where the Scan Type have to be specified:
- 'BUSINESS_CARD'
- 'EXPENSE_RECEIPT'
- 'INVOICE'
There are also separate methods for each type:
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.
- scan_type_, required parameter to specify the type to be processed. Possible values are 'BUSINESS_CARD', 'EXPENSE_RECEIPT' and 'INVOICE'.
- 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 Configuration (link to be added) to use. If not specified, the configuration specified in Machine Learning Pre-trained Models (link to be added) 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.
scan_type_ => 'INVOICE', -- Scan type ('BUSINESS_CARD' / 'EXPENSE_RECEIPT' / 'INVOICE').
response_format_ => 'JSON', -- Response format ('JSON' / 'IFS_MESSAGE').
ml_configuration_id_ => 'DEFAULT'); -- Configuration ID to use.
END;
See the separate methods above for response examples for the different types.
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.
- scan_type_, required parameter to specify the type to be processed. Possible values are 'BUSINESS_CARD', 'EXPENSE_RECEIPT' and 'INVOICE'.
- ml_configuration_id_, optional parameter to specify the Configuration ID from Machine Learning Configuration (link to be added) to use. If not specified, the configuration specified in Machine Learning Pre-trained Models (link to be added) 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.
scan_type_ => 'INVOICE', -- Scan type ('BUSINESS_CARD' / 'EXPENSE_RECEIPT' / 'INVOICE').
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.