|
Pep 0.4 API Documentation | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.osu.ling.pep.Pep
public class Pep
Command line front end for Earley parsers
.
In addition to tokenizing input strings and loading the Grammar
that
a parser will use, Pep also a listens
for events
from the Earley parsers it invokes. An example invocation might be something
like:
pep -g samples/miniscule.xml -s S the boy left -v
echo "the boy left" | pep -g samples/miniscule.xml -v 2 -s S -
samples/miniscule.xml
for the
seed category
S
and the input
string "the boy left
". Example (2) shows how to
configure Pep to read input from the standard input stream. For either of
these commands, Pep prints out the result of the parse as well as all
parse trees
for the specified string.
EarleyParser
Method Summary | |
---|---|
void |
edgeCompleted(EdgeEvent edgeEvent)
Consumes events generated when edges are added to the parser's chart because of completion. |
void |
edgePredicted(EdgeEvent edgeEvent)
Consumes events generated when edges are added to the parser's chart because of prediction. |
void |
edgeScanned(EdgeEvent edgeEvent)
Consumes events generated when the parser scans a token from the input string. |
static void |
main(String[] args)
Invokes Pep from the command line. |
void |
optionSet(ParserOptionEvent optionEvent)
Consumes events generated when options are set on the parser. |
void |
parseComplete(ParseEvent parseEvent)
Consumes events generated when the parser completes a parse. |
void |
parseError(ParseErrorEvent parseErrorEvent)
Notifies a listener that an error occurred during parsing. |
void |
parseMessage(ParseEvent parseEvent,
String message)
Notifies the listener of a message from the parser. |
void |
parserSeeded(EdgeEvent edgeEvent)
Consumes events generated when the parser is seeded. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void edgeCompleted(EdgeEvent edgeEvent)
edgeCompleted
in interface ParserListener
edgeEvent
- An event containing the added edge.public void edgePredicted(EdgeEvent edgeEvent)
edgePredicted
in interface ParserListener
edgeEvent
- An event containing the added edge.public void edgeScanned(EdgeEvent edgeEvent)
edgeScanned
in interface ParserListener
edgeEvent
- An event containing the edge created on the basis of
scanning a token.public static final void main(String[] args)
The main work this method does, apart from tokenizing the arguments and
input tokens, is to load and parse the XML grammar file (as specified
by -g
or --grammar
). If any of the arguments
-g
, --grammar
, -s
,
--seed
, -o
, --option
, occur
with no argument following, this method prints an error notifying the
user.
args
- The expected arguments are as follows, and can occur in
any particular order:
-g|--grammar <grammar file>
-s|--seed <seed category>
-v|--verbose {verbosity level}
-o|--option <OPTION_NAME=value>
-h|--help (prints usage information)
<token1 ... tokenn>
(or -
for standard input)OPTION_NAME
must be the name of one of the recognized
options
. If -h
or
--help
occur anywhere in the arguments, usage information
is printed and no parsing takes place.public void optionSet(ParserOptionEvent optionEvent)
optionSet
in interface ParserListener
optionEvent
- The event containing the newly set option and its
value.public void parseComplete(ParseEvent parseEvent)
parseComplete
in interface ParserListener
parseEvent
- An event containing the completed parse
.public void parseError(ParseErrorEvent parseErrorEvent) throws PepException
ParserListener
parseError
in interface ParserListener
parseErrorEvent
- An error event containing the parse that was
in progress and the error that occurred.
PepException
- If the listener does not wish to handle the
exception, it can re-throw the cause of the parse error event.public void parseMessage(ParseEvent parseEvent, String message)
ParserListener
parseMessage
in interface ParserListener
parseEvent
- A parse event containing the parse in progress.message
- The message.public void parserSeeded(EdgeEvent edgeEvent)
parserSeeded
in interface ParserListener
edgeEvent
- An event containing the added edge.
|
Pep: Pep is an Earley parser | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the overview file.