pub struct CykParser<'a> {
pub grammar: &'a ContextFreeGrammar,
}Expand description
A CYK (Cocke–Younger–Kasami) parser for CFGs in CNF.
Fields§
§grammar: &'a ContextFreeGrammarThe grammar (must be in CNF).
Implementations§
Source§impl<'a> CykParser<'a>
impl<'a> CykParser<'a>
Sourcepub fn new(grammar: &'a ContextFreeGrammar) -> Self
pub fn new(grammar: &'a ContextFreeGrammar) -> Self
Create a new CYK parser.
Sourcepub fn parse(&self, input: &[usize]) -> bool
pub fn parse(&self, input: &[usize]) -> bool
Run CYK on a sequence of terminal indices. Returns true iff the input is in L(grammar).
Sourcepub fn count_parses(&self, input: &[usize]) -> usize
pub fn count_parses(&self, input: &[usize]) -> usize
Count the number of parse trees (ambiguity measure).
Auto Trait Implementations§
impl<'a> Freeze for CykParser<'a>
impl<'a> RefUnwindSafe for CykParser<'a>
impl<'a> Send for CykParser<'a>
impl<'a> Sync for CykParser<'a>
impl<'a> Unpin for CykParser<'a>
impl<'a> UnsafeUnpin for CykParser<'a>
impl<'a> UnwindSafe for CykParser<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more