|
Formatron v0.4.9
Formatron empowers everyone to control the output format of language models with minimal overhead.
|
An extractor that uses multiple extractors to extract data. More...
Public Member Functions | |
| __init__ (self, typing.Iterable[Extractor] choices, str capture_name, str nonterminal) | |
| Initialize the choice extractor. | |
| typing.Optional[tuple[str, typing.Any]] | extract (self, str input_str) |
| Extract data from the input string using the first succeeding extractor. | |
Public Member Functions inherited from formatron.extractor.NonterminalExtractor | |
| str | nonterminal (self) |
| Get the nonterminal of the extractor. | |
| str | kbnf_reference (self) |
Public Member Functions inherited from formatron.extractor.Extractor | |
| __str__ (self) | |
| typing.Optional[str] | capture_name (self) |
Get the name of the capture, or None if the extractor does not capture. | |
Protected Attributes | |
| _choices | |
Protected Attributes inherited from formatron.extractor.NonterminalExtractor | |
| _nonterminal | |
Protected Attributes inherited from formatron.extractor.Extractor | |
| _capture_name | |
Properties | |
| str | kbnf_definition (self) |
An extractor that uses multiple extractors to extract data.
It stops at the first succeeding extractor.
Definition at line 194 of file extractor.py.
| formatron.extractor.ChoiceExtractor.__init__ | ( | self, | |
| typing.Iterable[Extractor] | choices, | ||
| str | capture_name, | ||
| str | nonterminal ) |
Initialize the choice extractor.
| choices | The extractors to choose from. The order determines the extractors' priority. |
| capture_name | The name of the capture, or None if the extractor does not capture. |
| nonterminal | The nonterminal representing the extractor. |
Reimplemented from formatron.extractor.NonterminalExtractor.
Definition at line 204 of file extractor.py.
| typing.Optional[tuple[str, typing.Any]] formatron.extractor.ChoiceExtractor.extract | ( | self, | |
| str | input_str ) |
Extract data from the input string using the first succeeding extractor.
| input_str | The input string. |
None if all extractors failed. Reimplemented from formatron.extractor.Extractor.
Definition at line 216 of file extractor.py.
| str formatron.extractor.ChoiceExtractor.kbnf_definition | ( | self | ) |
Reimplemented from formatron.extractor.Extractor.
Definition at line 231 of file extractor.py.
|
protected |
Definition at line 206 of file extractor.py.