Home | Trees | Index | Help |
|
---|
Package nltk_lite :: Package parse :: Module sr :: Class SteppingShiftReduce |
|
object
--+ |ParseI
--+ |AbstractParse
--+ |ShiftReduce
--+ | SteppingShiftReduce
A ShiftReduce
that allows you to setp through the parsing
process, performing a single operation at a time. It also allows you to
change the parser's grammar midway through parsing a text.
initialize
method is used to start parsing a text.
shift
performs a single shift operation, and
reduce
performs a single reduce operation. step
will perform a single reduce operation if possible; otherwise, it will
perform a single shift operation. parses
returns the set of
parses that have been found by the parser.
See Also: nltk.cfg
Method Summary | |
---|---|
Create a new ShiftReduce , that uses grammar
to parse texts. | |
get_parse_list(self,
token)
| |
Start parsing a given text. | |
list of Tree
|
Return a list of the parses that have been found by this parser so far. |
Production or None
|
Use production to combine the rightmost stack elements
into a single Tree . |
list of Production
|
Return a list of the productions for which reductions are available for the current parser state. |
list of String
|
Return the portion of the text that is not yet covered by the stack. |
Change the grammar used to parse texts. | |
boolean
|
Move a token from the beginning of the remaining text to the end of the stack. |
list of String and
Tree
|
Return the parser's stack. |
Production or boolean
|
Perform a single parsing operation. |
boolean
|
Return the parser to its state before the most recent shift or reduce operation. |
Inherited from ShiftReduce :
get_parse ,
trace ,
_check_grammar ,
_match_rhs ,
_reduce ,
_shift ,
_trace_reduce ,
_trace_shift ,
_trace_stack
Inherited from AbstractParse :
grammar ,
parse
Inherited from ParseI :
get_parse_probs
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
|
Instance Variable Summary | |
---|---|
_history : A list of (stack, remaining_text) pairs, containing all
of the previous states of the parser. |
Method Details |
---|
__init__(self,
grammar,
trace=0)
Create a new |
initialize(self, token)Start parsing a given text. This sets the parser's stack to[] and sets its remaining text to
token['SUBTOKENS'] .
|
parses(self)
|
reduce(self, production=None)Useproduction to combine the rightmost stack elements
into a single Tree . If production does not
match the rightmost stack elements, then do nothing.
|
reducible_productions(self)
|
remaining_text(self)
|
set_grammar(self, grammar)Change the grammar used to parse texts.
|
shift(self)Move a token from the beginning of the remaining text to the end of the stack. If there are no more tokens in the remaining text, then do nothing.
|
stack(self)
|
step(self)Perform a single parsing operation. If a reduction is possible, then perform that reduction, and return the production that it is based on. Otherwise, if a shift is possible, then perform it, and return 1. Otherwise, return 0.
|
undo(self)Return the parser to its state before the most recent shift or reduce operation. Callingundo repeatedly return the
parser to successively earlier states. If no shift or reduce operations
have been performed, undo will make no changes.
|
Instance Variable Details |
---|
_historyA list of(stack, remaining_text) pairs, containing all
of the previous states of the parser. This history is used to implement
the undo operation.
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Tue Sep 5 09:37:21 2006 | http://epydoc.sf.net |