edu.stanford.nlp.ie.pcfg
Class Parser

java.lang.Object
  |
  +--edu.stanford.nlp.ie.pcfg.Parser

public class Parser
extends Object

A "parse server" that runs Dan Klein's v2 parser. The Parser runs independently of any programs that call it. Other programs create a socket connection with the Parser to tell it that they'd like to start parsing. Then sentence/parse information is exchanged via file. In general, Dan's v2 parser takes about 10 minutes to start running. The parse server allows users to avoid this start-up cost. Parse sentence limit: 50 words. Note: you'll need to use the "java -Xmx1500m" option to get this to run. Also note: the nlp machines do not allow users to allocate java more than 1500m. Thus 50 words is an effective limit on the length of sentence that can be parsed by Dan's parser on the nlp machines (so far as I can tell). Note that a single executing parser server can only handle one client request at a time. However, the user can run separate parsers on different ports.


Field Summary
static String fn
          default prefix for file used to exchange parse information.
static int portNumber
          default port number.
static String ptb
          default location for the Penn Treebank data.
 
Constructor Summary
Parser()
           
 
Method Summary
static void main(String[] args)
          runs the parser server.
static Tree Parse(List sentence)
          Asks the parser server to parse a sentence.
static Tree Parse(List sentence, int portNumber)
          Asks the parser server to parse a sentence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

portNumber

public static int portNumber
default port number.


fn

public static String fn
default prefix for file used to exchange parse information. the parser will concat the port number to the end of this (to avoid conflicts between parsers running on different ports).


ptb

public static String ptb
default location for the Penn Treebank data.

Constructor Detail

Parser

public Parser()
Method Detail

main

public static void main(String[] args)
                 throws Exception
runs the parser server. the parser catches exceptions within its repeat loops, i.e., if something goes wrong, the parser will just "restart" and listen for new parse requests (this doesn't actually reinitialize the LexicalizedParser). Initializing the LexicalizedParser takes about 10 minutes; don't run a client until the server announces that it has finished initializing the parser (the last line of output should be "done").

Parameters:
args - expects two arguments. args[0]: port number. by default the server and client run on port 8888. args[1]: location of Penn Treebank. This should be something of the form .../Treebank3/parsed/mrg/wsj. See ptb for an example of what to use when working on ah.
Exception

Parse

public static Tree Parse(List sentence,
                         int portNumber)
                  throws IOException
Asks the parser server to parse a sentence. Remember that the server can only handle one client at a time. The server and client must be running on the same host, with the same port number.

Parameters:
sentence - a list of strings (NOT XLabels!)
Returns:
a parsed tree
IOException

Parse

public static Tree Parse(List sentence)
                  throws IOException
Asks the parser server to parse a sentence. Remember that the server can only handle one client at a time. The server and client must be running on the same host, with the same port number. Uses the default port number (8888).

Parameters:
sentence - a list of strings (NOT XLabels!)
Returns:
a parsed tree
IOException


Stanford NLP Group