Parsing Engine

danbikel.parser
Class EMParser

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by danbikel.switchboard.AbstractSwitchboardUser
              extended by danbikel.switchboard.AbstractClient
                  extended by danbikel.parser.Parser
                      extended by danbikel.parser.EMParser
All Implemented Interfaces:
ParserRemote, Settings.Change, Client, SwitchboardUser, Serializable, Runnable, Remote

public class EMParser
extends Parser

An EM parsing client. This class constrain-parses sentences by implementing the AbstractClient.process(Object) method of its superclass. All top-level probabilities are computed by a DecoderServer object, which is either local or is a stub whose methods are invoked via RMI. The actual parsing is implemented in the EMDecoder class.

See Also:
AbstractClient, DecoderServer, EMDecoder, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class danbikel.switchboard.AbstractSwitchboardUser
AbstractSwitchboardUser.Alive, AbstractSwitchboardUser.SBUserRetry
 
Field Summary
 
Fields inherited from class danbikel.parser.Parser
decoder, derivedDataFilename, err, grabSBSettings, inputFilename, internalInputFilename, internalOutputFilename, intTypeArr, invocationTargetExceptionMsg, keepAllWords, localServer, newDecoderTypeArr, numClients, outputFilename, outputFilenameSuffix, parserClass, sent, server, settingsFilename, standAlone, stringTypeArr, switchboardName
 
Fields inherited from class danbikel.switchboard.AbstractClient
defaultNextObjectInterval, failover, faultTolerant, nextObjectInterval, rand, retries, serverId, sleepTime
 
Fields inherited from class danbikel.switchboard.AbstractSwitchboardUser
aliveSynch, aliveTimeout, defaultMaxSwitchboardTries, defaultTimeout, dieSynch, id, infiniteTries, maxSwitchboardTries, registered, switchboard, timeout, timeToDie
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
EMParser(DecoderServerRemote server)
          Constructs a new EM parsing client using the specified DecoderServerRemote instance for probability lookups and for other resources needed by the decoder.
EMParser(int timeout)
          Constructs an EM parsing client with the specified socket timeout value.
EMParser(int timeout, int port)
          Construct an EM parsing client with the specified socket timeout value using the specified port on which to accept RMI connections.
EMParser(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
          Constructs an EM parsing client using the specified port on which to accept RMI connections and using the specified socket factories for client and server socket creation.
EMParser(String derivedDataFilename)
          Constructs a new EM parsing client with an internal DecoderServerRemote instance constructed using the specified derived data filename.
 
Method Summary
protected  Decoder getNewDecoder(int id, DecoderServerRemote server)
          Gets a new Decoder instance that uses the specified DecoderServerRemote instance.
static void main(String[] args)
          Contacts the switchboard, registers this parsing client and gets sentences from the switchboard, parses them and returns them, until the switchboard indicates there are no more sentences to process.
 CountsTable parseAndCollectEventCounts(SexpList sent)
          Collect expected counts for the specified partial parse tree/sentence.
protected  SexpList preProcess(Sexp tree)
          Instead of simply invoking the Training.preProcess(Sexp) method, this method selectively invokes only some of the preprocessing methods of Training, so as to leave the rest of the transformations unconstrained.
protected  Object process(Object obj)
          Collect expected counts for the specified partial parse tree/sentence.
 
Methods inherited from class danbikel.parser.Parser
checkSettings, convertUnknownWords, getConstraintsFromTree, getFailover, getFile, getFile, getNewDecoderServer, getNewParser, getNewParser, getRetries, getRetrySleep, getServer, getTagLists, getTagListsFromTree, getTimeout, getWords, getWordsFromTree, getWordsFromTree, parse, processInputFile, run, sentContainsWordsAndTags, setInternalFilenames, setSettingsFromSwitchboard, switchboardFailure, tolerateFaults, update, wordTagList
 
Methods inherited from class danbikel.switchboard.AbstractClient
cleanup, disableHttp, getFaultTolerantServer, processObjects, processObjectsThenDie, register, reRegister, serverDown, setNextObjectInterval, setPolicyFile, setPolicyFile, sleepRandom
 
Methods inherited from class danbikel.switchboard.AbstractSwitchboardUser
alive, die, disableHttp, getAliveTimeout, getSwitchboard, getSwitchboard, getSwitchboard, getSwitchboard, getSwitchboard, getSwitchboard, host, id, nonZeroTimeout, setPolicyFile, setPolicyFile, startAliveThread, unexportWhenDead
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface danbikel.switchboard.Client
serverDown
 
Methods inherited from interface danbikel.switchboard.SwitchboardUser
alive, die, host, id
 

Constructor Detail

EMParser

public EMParser(String derivedDataFilename)
         throws RemoteException,
                ClassNotFoundException,
                NoSuchMethodException,
                InvocationTargetException,
                IllegalAccessException,
                InstantiationException
Constructs a new EM parsing client with an internal DecoderServerRemote instance constructed using the specified derived data filename.

Parameters:
derivedDataFilename - the derived data filename (output by the Trainer) to use for constructing an internal DecoderServerRemote instance
Throws:
RemoteException - if this method is called from a remote stub and any of the other exceptions are thrown
ClassNotFoundException - if the class specified by Settings.decoderServerClass is not found in this JVM's class path
NoSuchMethodException - if the class specified by Settings.decoderServerClass has no constructor taking a single String as an argument
InvocationTargetException - if the constructor of the class specified by Settings.decoderServerClass (the invocation target) throws an underlying exception
IllegalAccessException - if the constructor of the class specified by Settings.decoderServerClass is not accessible from this class in this package
InstantiationException - if the class specified by Settings.decoderServerClass is not instantiable because it is either an interface or abstract class

EMParser

public EMParser(DecoderServerRemote server)
         throws RemoteException
Constructs a new EM parsing client using the specified DecoderServerRemote instance for probability lookups and for other resources needed by the decoder.

Parameters:
server - the server for this client's Decoder to use
Throws:
RemoteException

EMParser

public EMParser(int timeout)
         throws RemoteException
Constructs an EM parsing client with the specified socket timeout value.

Parameters:
timeout - the time in milliseconds before client-side (switchboard-side) sockets used for this remote object time out; a value of 0 specifies infinite timeout, which is dangerous
Throws:
RemoteException

EMParser

public EMParser(int timeout,
                int port)
         throws RemoteException
Construct an EM parsing client with the specified socket timeout value using the specified port on which to accept RMI connections.

Parameters:
timeout - the time in milliseconds before client-side (switchboard-side) sockets used for this remote object time out; a value of 0 specifies infinite timeout, which is dangerous
port - the port on which this remote object is to receive remote method invocations
Throws:
RemoteException

EMParser

public EMParser(int port,
                RMIClientSocketFactory csf,
                RMIServerSocketFactory ssf)
         throws RemoteException
Constructs an EM parsing client using the specified port on which to accept RMI connections and using the specified socket factories for client and server socket creation.

Parameters:
port - the port on which this remote object is to receive remote method invocations
csf - the socket factory for creating sockets for this RMI client
ssf - the socket factory for creating sockets for this RMI server
Throws:
RemoteException
Method Detail

getNewDecoder

protected Decoder getNewDecoder(int id,
                                DecoderServerRemote server)
Gets a new Decoder instance that uses the specified DecoderServerRemote instance.

Overrides:
getNewDecoder in class Parser
Parameters:
id - the id of this parsing client
server - the decoding server that the new decoder will use
Returns:
a new Decoder instance that uses the specified DecoderServerRemote instance

process

protected Object process(Object obj)
                  throws RemoteException
Collect expected counts for the specified partial parse tree/sentence.

Overrides:
process in class Parser
Parameters:
obj - a SexpList that is in one of the three formats accepted by the decoder, but normally should be a (partial) parse tree from which constraints will be derived
Returns:
a CountsTable instance containing a mapping of all top-level (i.e., maximal context) events (of type TrainerEvent) to their expected counts under the current model
Throws:
RemoteException
See Also:
Parser.parse(SexpList)

parseAndCollectEventCounts

public CountsTable parseAndCollectEventCounts(SexpList sent)
                                       throws RemoteException
Collect expected counts for the specified partial parse tree/sentence.

Parameters:
sent - a list that is in one of the three formats accepted by the decoder, but normally should be a (partial) parse tree from which constraints will be derived
Returns:
a mapping of all top-level (i.e., maximal context) events (of type TrainerEvent) to their expected counts under the current model
Throws:
RemoteException

preProcess

protected SexpList preProcess(Sexp tree)
Instead of simply invoking the Training.preProcess(Sexp) method, this method selectively invokes only some of the preprocessing methods of Training, so as to leave the rest of the transformations unconstrained.

Parameters:
tree - the tree to be preprocessed
Returns:
a preprocessed version of the specified parse tree

main

public static void main(String[] args)
Contacts the switchboard, registers this parsing client and gets sentences from the switchboard, parses them and returns them, until the switchboard indicates there are no more sentences to process. Multiple such clients may be created.


Parsing Engine

Author: Dan Bikel.