Home | Trees | Index | Help |
|
---|
Package nltk_lite :: Package parse :: Module rd :: Class RecursiveDescent |
|
object
--+ |ParseI
--+ |AbstractParse
--+ | RecursiveDescent
SteppingRecursiveDescent
A simple top-down CFG parser that parses texts by recursively
expanding the fringe of a Tree
, and matching it against a
text.
RecursiveDescent
uses a list of tree locations called a
frontier to
remember which subtrees have not yet been expanded and which leaves have
not yet been matched against the text. Each tree location consists of a
list of child indices specifying the path from the root of the tree to a
subtree or a leaf; see the reference documentation for Tree
for more information about tree locations.
See Also: nltk.cfg
Method Summary | |
---|---|
Create a new RecursiveDescent , that uses
grammar to parse texts. | |
get_parse_list(self,
tokens)
| |
None
|
Set the level of tracing output that should be generated when parsing a text. |
list of Tree
|
Return a list of all parses that can be generated by expanding the first element of frontier with production . |
list of Tree
|
Return a list of all parses that can be generated by matching the first element of frontier against the first token in
rtext . |
list of Tree
|
Recursively expand and match each elements of tree
specified by frontier , to cover
remaining_text . |
Tree
|
Return the Tree that is licensed by production . |
_trace_backtrack(self,
tree,
frontier,
toks)
| |
_trace_expand(self,
tree,
frontier,
production)
| |
None
|
Print trace output displaying the fringe of tree . |
_trace_match(self,
tree,
frontier,
tok)
| |
_trace_start(self,
tree,
frontier,
text)
| |
_trace_succeed(self,
tree,
frontier)
| |
None
|
Print trace output displaying the parser's current state. |
Inherited from AbstractParse :
get_parse ,
grammar ,
parse
Inherited from ParseI :
get_parse_probs
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
|
Method Details |
---|
__init__(self,
grammar,
trace=0)
Create a new |
trace(self, trace=2)Set the level of tracing output that should be generated when parsing a text.
|
_expand(self, remaining_text, tree, frontier, production=None)
|
_match(self, rtext, tree, frontier)
|
_parse(self, remaining_text, tree, frontier)Recursively expand and match each elements oftree
specified by frontier , to cover
remaining_text . Return a list of all parses found.
|
_production_to_tree(self, production)
|
_trace_fringe(self, tree, treeloc=None)Print trace output displaying the fringe oftree . The
fringe of tree consists of all of its leaves and all of
its childless subtrees.
|
_trace_tree(self, tree, frontier, operation)Print trace output displaying the parser's current state.
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Tue Sep 5 09:37:22 2006 | http://epydoc.sf.net |