Constructor Grammar
- Namespace
- LMKit.TextGeneration.Sampling
- Assembly
- LM-Kit.NET.dll
Grammar(string, string)
Initializes a new instance of the Grammar class by parsing a string containing GGML BNF (Backus-Naur Form) grammar definitions. For more information on GGML BNF, see the GGML BNF documentation.
public Grammar(string gbnf, string startRule = "root")
Parameters
gbnf
stringThe string containing the grammar definitions in GGML BNF format.
startRule
stringThe name of the start rule for this grammar. Defaults to "root".
Exceptions
- GrammarParsingException
Thrown if the input string is malformed or cannot be parsed into a valid grammar.
Grammar(PredefinedGrammar)
Initializes a new instance of the Grammar class using a predefined grammar type.
public Grammar(Grammar.PredefinedGrammar type)
Parameters
type
Grammar.PredefinedGrammarThe type of predefined grammar to create.
Exceptions
- ArgumentException
Thrown if the specified
type
is not recognized.