StructuredOutputParser<T>

Models & Types ยท AiDotNet.Postprocessing.Document

StructuredOutputParser - Parses document AI outputs into structured data formats.

Inheritance: PostprocessorBase<T, string, Dictionary<string, string>> โ†’ StructuredOutputParser<T>

Implements: IDisposable

For Beginners

AI models output text, but applications need structured data. This tool bridges that gap:

  • Convert OCR text to JSON
  • Extract key-value pairs
  • Build tabular data
  • Validate against schemas

Key features:

  • Multiple output formats
  • Schema validation
  • Custom parsing rules
  • Error handling

Example usage:

How It Works

StructuredOutputParser converts raw model outputs and OCR results into structured formats like JSON, tables, key-value pairs, and custom schemas.

Constructors

Constructor Summary
StructuredOutputParser() Creates a new StructuredOutputParser with default settings.

Properties

Property Summary
bool SupportsInverse { get; } Structured output parser does not support inverse transformation.

Methods

Method Summary
Dictionary<string, string> ParseForm(string text, IEnumerable<string> fieldLabels) Parses a form into a structured object.
Dictionary<string, string> ParseKeyValuePairs(string text) Parses text into key-value pairs.
IList<Dictionary<string, string>> ParseTableWithHeaders(string text, string delimiter) Parses tabular text into a list of dictionaries using the first row as headers.
IList<IList<string>> ParseTable(string text, string delimiter) Parses tabular text into a list of rows.
InvoiceData ParseInvoice(string text) Parses an invoice into a structured format.
ReceiptData ParseReceipt(string text) Parses a receipt into a structured format.
ValidationResult ValidateAgainstSchema(Dictionary<string, object> data, DocumentSchema schema) Validates parsed data against a schema.
string ParseToJson(string text, IEnumerable<FieldExtractionRule> fieldRules) Parses text into a JSON object based on extraction rules.
void Dispose()