Table of Contents

Method CreateJsonGrammarFromExtractionElements

Namespace
LMKit.TextGeneration.Sampling
Assembly
LM-Kit.NET.dll

CreateJsonGrammarFromExtractionElements(IEnumerable<TextExtractionElement>)

Creates a new instance of the Grammar class based on a collection of TextExtractionElement objects. Each TextExtractionElement represents a field or value to be extracted from a JSON structure.

public static Grammar CreateJsonGrammarFromExtractionElements(IEnumerable<TextExtractionElement> extractionElements)

Parameters

extractionElements IEnumerable<TextExtractionElement>

A collection of TextExtractionElement objects that define the fields or values to extract. Each TextExtractionElement corresponds to a component in the JSON structure that will be used to create the Grammar.

Returns

Grammar

A new instance of the Grammar class based on the provided extraction elements. The generated grammar will define how to extract specific fields from a JSON document.

Exceptions

ArgumentException

Thrown if the extractionElements collection is null or empty. This exception indicates that the method requires at least one extraction element to create a valid Grammar instance.