Struct cfg::BinarizedCfg
[−]
[src]
pub struct BinarizedCfg<H = NullHistory> { // some fields omitted }
Representation for grammars where right-hand sides of all rules have at most two symbols.
Methods
impl<H> BinarizedCfg<H>
fn new() -> Self
Creates a BinarizedCfg.
fn with_sym_source(sym_source: SymbolSource) -> Self
Creates an empty BinarizedCfg with the given symbol source.
fn from_context_free<'a, G>(this: &'a G) -> BinarizedCfg<H> where G: ContextFree<History=H>, &'a G: ContextFreeRef<'a, Target=G>, H: Binarize + Clone + 'static
Creates a BinarizedCfg by binarizing a context-free grammar.
fn sort(&mut self)
Sorts the rule array.
fn sort_by<F>(&mut self, compare: F) where F: FnMut(&BinarizedRule<H>, &BinarizedRule<H>) -> Ordering
Sorts the rule array in place, using the argument to compare elements.
fn dedup(&mut self)
Removes consecutive duplicate rules.
impl<H> BinarizedCfg<H> where H: Binarize
fn sym<T>(&mut self) -> T where T: SymbolContainer
Returns generated symbols.
fn next_sym(&mut self) -> Symbol
Generates a new unique symbol.
fn num_syms(&self) -> usize
Returns the number of symbols in use.
impl<H> BinarizedCfg<H> where H: Binarize + Clone + EliminateNulling
fn eliminate_nulling_rules(&mut self) -> BinarizedCfg<H>
Eliminates all rules of the form A ::= epsilon
.
In other words, this splits off the set of nulling rules.
The language represented by the grammar is preserved, except for the possible lack of the empty string. Unproductive rules aren't preserved.