Formatron v0.4.11
Formatron empowers everyone to control the output format of language models with minimal overhead.
All Classes Namespaces Files Functions Variables
formatron.formats.regex.RegexComplementExtractor Class Reference

An extractor that extracts data by matching a regex complement. More...

Inheritance diagram for formatron.formats.regex.RegexComplementExtractor:
formatron.extractor.NonterminalExtractor formatron.extractor.Extractor

Public Member Functions

 __init__ (self, str regex, str capture_name, str nonterminal)
 Initialize the regex complement extractor.
 
typing.Optional[tuple[str, str]] extract (self, str input_str)
 Extract the data by matching a regex complement.
 
- 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

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

Properties

str kbnf_definition (self)
 

Detailed Description

An extractor that extracts data by matching a regex complement.

Definition at line 59 of file regex.py.

Constructor & Destructor Documentation

◆ __init__()

formatron.formats.regex.RegexComplementExtractor.__init__ ( self,
str regex,
str capture_name,
str nonterminal )

Initialize the regex complement extractor.

Reimplemented from formatron.extractor.NonterminalExtractor.

Definition at line 64 of file regex.py.

Member Function Documentation

◆ extract()

typing.Optional[tuple[str, str]] formatron.formats.regex.RegexComplementExtractor.extract ( self,
str input_str )

Extract the data by matching a regex complement.

Specifically, the string until the first character in the first match of the regex is extracted if there is a match, or the entire string is extracted if there is no match.

Reimplemented from formatron.extractor.Extractor.

Definition at line 74 of file regex.py.

◆ kbnf_definition()

str formatron.formats.regex.RegexComplementExtractor.kbnf_definition ( self)

Reimplemented from formatron.extractor.Extractor.

Definition at line 88 of file regex.py.

Member Data Documentation

◆ _regex

formatron.formats.regex.RegexComplementExtractor._regex
protected

Definition at line 66 of file regex.py.


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