Formatron v0.4.2
Formatron empowers everyone to control the output format of language models with minimal overhead.
Loading...
Searching...
No Matches
formatron.extractor.NonterminalExtractor Class Reference

An extractor that extracts data corresponding to a nonterminal. More...

Inheritance diagram for formatron.extractor.NonterminalExtractor:
formatron.extractor.Extractor formatron.extractor.ChoiceExtractor formatron.extractor.SubstringExtractor formatron.formats.json.JsonExtractor formatron.formats.regex.RegexExtractor

Public Member Functions

 __init__ (self, str nonterminal, typing.Optional[str] capture_name=None)
 Initialize the nonterminal extractor.
 
- Public Member Functions inherited from formatron.extractor.Extractor
typing.Optional[tuple[str, typing.Any]] extract (self, str input_str)
 Extract data from the input string, or None if the extraction failed.
 
 __str__ (self)
 
str kbnf_definition (self)
 
typing.Optional[str] capture_name (self)
 Get the name of the capture, or None if the extractor does not capture.
 

Protected Attributes

 _nonterminal
 
- Protected Attributes inherited from formatron.extractor.Extractor
 _capture_name
 

Properties

str nonterminal (self)
 Get the nonterminal of the extractor.
 
str kbnf_reference (self)
 

Detailed Description

An extractor that extracts data corresponding to a nonterminal.

Definition at line 98 of file extractor.py.

Constructor & Destructor Documentation

◆ __init__()

formatron.extractor.NonterminalExtractor.__init__ ( self,
str nonterminal,
typing.Optional[str] capture_name = None )

Member Function Documentation

◆ kbnf_reference()

str formatron.extractor.NonterminalExtractor.kbnf_reference ( self)

Reimplemented from formatron.extractor.Extractor.

Definition at line 134 of file extractor.py.

◆ nonterminal()

str formatron.extractor.NonterminalExtractor.nonterminal ( self)

Get the nonterminal of the extractor.

Definition at line 121 of file extractor.py.

Member Data Documentation

◆ _nonterminal

formatron.extractor.NonterminalExtractor._nonterminal
protected

Definition at line 106 of file extractor.py.


The documentation for this class was generated from the following file: