Skip to main content

Get-Template-Recognition

Command Description

Get specified filed result of custom template recognition result

Command Prototype

arrayRet = Mage.ExtractOCRTemplateInfo(jsonRet,extractor,template_name,field_name,update_time)

Parameter Description

ParameterRequiredTypeDefaultDescription
jsonRetTruereferencejsonRetUse the variable output to the "Screen Customer Template" command, such as the "PDF Custom Template" command, you need to use the value of traverse an array
extractorTrueexpression{}Select the recognizer of the custom template
template_nameTruestring""Select a custom template name
field_nameTruestring""Select the field in the template
update_timeTruestring""Cannot be modified. Get template update time automatically when the command is selected. If the result is not consistent with that of custom template recognition, it will be prompted at run time

return

arrayRet,The variable used to save the output of the command.

Demo

Dim jsonRet = {"ai_function" : "ocr_template","msgId" : "7bc9a3eb20922fd065b60eb4f934e573","page_number" : 1,"raw" : {"image_angle" : 0, "items" : [],"rotated_image_height" : 0,"rotated_image_width" : 0,"struct_content" : null,"tables" : []},"results" : [ {"field_name" : "student number","results" : ["2021005"]},{"field_name" : "name","results" : ["Sun Qi"]}, {"field_name" : "Gender","results" : ["Male"]},{"field_name" : "Exam Date","results" : ["2020.03.10"]} ,{"field_name" : "Grade","results" : ["Senior Grade"]},{"field_name" : "Chinese","results" : ["85"]} ,{"field_name" : "Math","results" : ["79"]},{"field_name" : "English","results" : ["85"]},{ "field_name" : "History","results" : ["75"]},{"field_name" : "Chemistry","results" : ["79"]}],"template_hash " : "AAAAAAAAAAAAAAAAAAAAAC2Thko=00","template_name" : "Result analysis","update_time" : "2021-08-31 12:20:53"}  // Test data 
Dim extractor={"Pubkey":"","Secret":"","Url":""} // Obtained from mage, you need to create the corresponding model in "Custom Template Recognition" first
Dim template_name="" // template name
Dim field_name="" // Field name

TracePrint "--------------------Get the field list of the template--------------------"
// --------------------------------------------------------
// [Remarks] Get the field list of the template
// Input parameter 1:
// jsonRet--template recognition result
// Input parameter 2:
// extractor--recognizer, select the mage recognizer to use
// Input parameter 3:
// template_name--template name
// Input parameter 4:
// field_name--field name
// Input parameter 5:
// update_time--update time

// Output parameters:
// arrayRet--The variable to which the output of the function call is saved

// 命令原型:arrayRet = Mage.ExtractOCRTemplateInfo(jsonRet,extractor,template_name,field_name,update_time)
// --------------------------------------------------------

arrayRet = Mage.ExtractOCRTemplateInfo(jsonRet,extractor,template_name,field_name,"")
Traceprint(arrayRet)