Document Understanding - Generative Extractor - Datatable as Input/Output

Hello!

Here we can see a quick example to use a Datatable to send the questions to the Generative Extractor.

The Extract Document Data activity doesn’t allow to have a dynamic number of questions, so we can use a Json string to send several questions in one line.

First create a datatable - dtInput, like:

transaction_id question answer
1 Number of words in doc? put answer here
2 First word in doc? put answer here
5 Choose your question? put answer here

Assign an string variable - sJsonQuestions

newtonsoft.Json.JsonConvert.SerializeObject(dtInput).ToString + " retrieve data with array json format [{transaction_id:,question:,answer:}]"

the last words in bold will ensure the output structure (this is important, without it the output structure can change or be empty). You can choose any other format.

Use this string as input to the Extract Document Data activity

image

After the Extract Document Data activity, we can use this to convert the output to datable again:

dtOutput = jsonConvert.DeserializeObject(of DataTable)(objExtraction.Data._0.Value.ToString)