Pep 0.4 API Documentation

edu.osu.ling.pep
Class Pep

java.lang.Object
  extended by edu.osu.ling.pep.Pep
All Implemented Interfaces:
ParserListener, EventListener

public class Pep
extends Object
implements ParserListener

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:

  1. pep -g samples/miniscule.xml -s S the boy left -v
  2. echo "the boy left" | pep -g samples/miniscule.xml -v 2 -s S -
The above commands cause Pep to create an Earley parser using the grammar specified in the file 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.

Version:
$LastChangedRevision: 1812 $
Author:
Scott Martin
See Also:
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

edgeCompleted

public void edgeCompleted(EdgeEvent edgeEvent)
Consumes events generated when edges are added to the parser's chart because of completion.

Specified by:
edgeCompleted in interface ParserListener
Parameters:
edgeEvent - An event containing the added edge.

edgePredicted

public void edgePredicted(EdgeEvent edgeEvent)
Consumes events generated when edges are added to the parser's chart because of prediction.

Specified by:
edgePredicted in interface ParserListener
Parameters:
edgeEvent - An event containing the added edge.

edgeScanned

public void edgeScanned(EdgeEvent edgeEvent)
Consumes events generated when the parser scans a token from the input string.

Specified by:
edgeScanned in interface ParserListener
Parameters:
edgeEvent - An event containing the edge created on the basis of scanning a token.

main

public static final void main(String[] args)
Invokes Pep from the command line.

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.

Parameters:
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.

optionSet

public void optionSet(ParserOptionEvent optionEvent)
Consumes events generated when options are set on the parser.

Specified by:
optionSet in interface ParserListener
Parameters:
optionEvent - The event containing the newly set option and its value.

parseComplete

public void parseComplete(ParseEvent parseEvent)
Consumes events generated when the parser completes a parse.

Specified by:
parseComplete in interface ParserListener
Parameters:
parseEvent - An event containing the completed parse.

parseError

public void parseError(ParseErrorEvent parseErrorEvent)
                throws PepException
Description copied from interface: ParserListener
Notifies a listener that an error occurred during parsing.

Specified by:
parseError in interface ParserListener
Parameters:
parseErrorEvent - An error event containing the parse that was in progress and the error that occurred.
Throws:
PepException - If the listener does not wish to handle the exception, it can re-throw the cause of the parse error event.

parseMessage

public void parseMessage(ParseEvent parseEvent,
                         String message)
Description copied from interface: ParserListener
Notifies the listener of a message from the parser.

Specified by:
parseMessage in interface ParserListener
Parameters:
parseEvent - A parse event containing the parse in progress.
message - The message.

parserSeeded

public void parserSeeded(EdgeEvent edgeEvent)
Consumes events generated when the parser is seeded.

Specified by:
parserSeeded in interface ParserListener
Parameters:
edgeEvent - An event containing the added edge.

Pep: Pep is an Earley parser

Pep API Documentation, Copyright © 2007 Scott Martin

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.