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

An extractor that extracts a literal string. More...

Inheritance diagram for formatron.extractor.LiteralExtractor:
formatron.extractor.Extractor

Public Member Functions

 __init__ (self, str literal)
 Initialize the literal extractor.
 
typing.Optional[tuple[str, str]] extract (self, str input_str)
 Extract the literal from the input string, or None if the literal is not found.
 
- 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

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

Properties

str kbnf_reference (self)
 
str kbnf_definition (self)
 

Detailed Description

An extractor that extracts a literal string.

Definition at line 143 of file extractor.py.

Constructor & Destructor Documentation

◆ __init__()

formatron.extractor.LiteralExtractor.__init__ ( self,
str literal )

Initialize the literal extractor.

It never captures since capturing a literal is redundant.

Parameters
literalThe literal string to extract.

Reimplemented from formatron.extractor.Extractor.

Definition at line 151 of file extractor.py.

Member Function Documentation

◆ extract()

typing.Optional[tuple[str, str]] formatron.extractor.LiteralExtractor.extract ( self,
str input_str )

Extract the literal from the input string, or None if the literal is not found.

Reimplemented from formatron.extractor.Extractor.

Definition at line 158 of file extractor.py.

◆ kbnf_definition()

str formatron.extractor.LiteralExtractor.kbnf_definition ( self)

Reimplemented from formatron.extractor.Extractor.

Definition at line 185 of file extractor.py.

◆ kbnf_reference()

str formatron.extractor.LiteralExtractor.kbnf_reference ( self)

Reimplemented from formatron.extractor.Extractor.

Definition at line 172 of file extractor.py.

Member Data Documentation

◆ _literal

formatron.extractor.LiteralExtractor._literal
protected

Definition at line 153 of file extractor.py.


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