|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.rmi.server.RemoteObject
java.rmi.server.RemoteServer
danbikel.switchboard.AbstractSwitchboardUser
danbikel.switchboard.AbstractServer
danbikel.parser.DecoderServer
public class DecoderServer
Provides probabilities and other resources needed by decoders.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class danbikel.switchboard.AbstractSwitchboardUser |
---|
AbstractSwitchboardUser.Alive, AbstractSwitchboardUser.SBUserRetry |
Field Summary | |
---|---|
protected boolean |
downcaseWords
The boolean value of Settings.downcaseWords . |
protected ModelCollection |
modelCollection
The model collection used by this decoder server. |
protected Word |
stopWord
The value of Training.stopSym() , cached here for convenience. |
protected int |
unknownWordThreshold
The integer value of Settings.unknownWordThreshold . |
Fields inherited from class danbikel.switchboard.AbstractServer |
---|
acceptClientsOnlyByRequest, maxClients |
Fields inherited from class danbikel.switchboard.AbstractSwitchboardUser |
---|
aliveSynch, aliveTimeout, className, defaultMaxSwitchboardTries, defaultTimeout, dieSynch, id, infiniteTries, maxSwitchboardTries, registered, switchboard, switchboardName, timeout, timeToDie |
Fields inherited from class java.rmi.server.RemoteObject |
---|
ref |
Fields inherited from interface danbikel.switchboard.Server |
---|
acceptUnlimitedClients |
Constructor Summary | |
---|---|
DecoderServer(int timeout)
Constructs a new server with the specified timeout value for its RMI sockets, to receive RMI calls on an anonymous port. |
|
DecoderServer(int maxClients,
boolean acceptClientsOnlyByRequest,
int timeout,
int port)
Constructs a new server that will accept no more than the specified number of clients, will optionally accept clients only by request, that will use the specified timeout for its RMI sockets and will accept RMI calls on the specified port. |
|
DecoderServer(int maxClients,
boolean acceptClientsOnlyByRequest,
int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
Constructs a new server that will accept no more than the specified number of clients, will optionally accept clients only by request, will accept RMI calls on the specified port and will use the specified socket factories to create its RMI sockets. |
|
DecoderServer(int timeout,
int port)
Constructs a new server with the specified timeout value for its RMI sockets, to receive RMI calls on the specified port. |
|
DecoderServer(int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
Constructs a new server that will accept RMI calls on the specified port, using the specified socket factories to create RMI sockets. |
|
DecoderServer(String mcFilename)
Constructs a non-exported DecoderServer object. |
Method Summary | |
---|---|
Sexp |
convertUnknownWord(Symbol originalWord,
int index)
Returns either the specified word untouched, or a 3-element list as would be created by DecoderServerRemote.convertUnknownWords(SexpList) . |
SexpList |
convertUnknownWords(SexpList sentence)
Replaces all unknown words in the specified sentence with three-element lists, where the first element is the word itself, the second element is a word-feature vector, as determined by the implementation of WordFeatures.features(Symbol,boolean) , and
the third element is Constants.trueSym if this word was never
observed during training or Constants.falseSym if it was
observed at least once during training. |
String |
getModelCacheStats()
A flow-through method for ModelCollection.getModelCacheStats() . |
protected static int |
getTimeout()
Obtains the timeout from Settings . |
Map |
headToParentMap()
A mapping from head labels to possible parent labels. |
Map |
leftSubcatMap()
Returns a map of Event objects to Set objects,
where each Event object is the last level of back-off
of the probability structure for left-side subcat generation and the
set contains all possible Subcat objects for that
most-general context. |
ProbabilityStructure |
leftSubcatProbStructure()
The probability structure for the submodel that generates subcats on the left-hand side of head constituents. |
double |
logPrior(int id,
TrainerEvent event)
Returns the prior probability for the lexicalized nonteminal encoded in the specified TrainerEvent , which should be an instance of
HeadEvent . |
double |
logProbGap(int id,
TrainerEvent event)
Returns the log of the probability of generating a gap. |
double |
logProbHead(int id,
TrainerEvent event)
Returns the log of the probability of generating a head child in the context of a particular parent (both the head to be generated and the parent are contained in the specified TrainerEvent object). |
double |
logProbHeadWithSubcats(int id,
TrainerEvent event)
Returns the log of the probability of generating a new head and its left and right subcat frames. |
double |
logProbLeftSubcat(int id,
TrainerEvent event)
Returns the log of the probability of generating a left subcat in the context of a particular parent and head (the subcat to be generated, the head and parent are all contained in the specified TrainerEvent
object). |
double |
logProbMod(int id,
TrainerEvent event)
Returns the log of the probability of generating a fully-lexicalized modifying nonterminal given a particular parent, head and other components of the syntactic context. |
double |
logProbModNT(int id,
TrainerEvent event)
Returns the log of the probability of generating a partially-lexicalized modifying nonterminal given a particular parent, head and other components of the syntactic context. |
double |
logProbRightSubcat(int id,
TrainerEvent event)
Returns the log of the probability of generating a right subcat in the context of a particular parent and head (the subcat to be generated, the head and parent are all contained in the specified TrainerEvent
object). |
double |
logProbSubcat(int id,
TrainerEvent event,
boolean side)
Invokes DecoderServerRemote.logProbLeftSubcat(int, TrainerEvent) or
DecoderServerRemote.logProbRightSubcat(int, TrainerEvent) depending on the value
of side . |
double |
logProbTop(int id,
TrainerEvent event)
Returns the log of the probability of generating the head nonterminal of an entire sentence. |
static void |
main(String[] args)
Starts a decoder server and registers it with the switchboard. |
Map |
modNonterminalMap()
A map of events from the last back-off level of the modifier nonterminal–generation submodel to the set of possible futures (typically, a future is a modifier label and its head word's part-of-speech tag). |
ProbabilityStructure |
modNonterminalProbStructure()
The probability structure for the submodel that generates modifiers of head constituents. |
CountsTable |
nonterminals()
Returns the nonterminals CountsTable of the internal
ModelCollection object. |
Map |
posMap()
Returns the map of vocabulary items to possible parts of speech, contained in the internal ModelCollection object. |
double |
probHead(int id,
TrainerEvent event)
Returns the probability of generating a head child in the context of a particular parent (both the head to be generated and the parent are contained in the specified TrainerEvent object). |
double |
probLeftSubcat(int id,
TrainerEvent event)
Returns the probability of generating a left subcat in the context of a particular parent and head (the subcat to be generated, the head and parent are all contained in the specified TrainerEvent
object). |
double |
probMod(int id,
TrainerEvent event)
Returns the probability of generating a fully-lexicalized modifying nonterminal given a particular parent, head and other components of the syntactic context. |
double |
probRightSubcat(int id,
TrainerEvent event)
Returns the probability of generating a right subcat in the context of a particular parent and head (the subcat to be generated, the head and parent are all contained in the specified TrainerEvent
object). |
double |
probTop(int id,
TrainerEvent event)
Returns the probability of generating the head nonterminal of an entire sentence. |
Set |
prunedPreterms()
A set of Sexp objects representing preterminals that were
pruned during training. |
Set |
prunedPunctuation()
Returns the set of preterminals ( Sexp objects) that were
punctuation elements that were “raised away” because they were
either at the beginning or end of a sentence. |
Map |
rightSubcatMap()
Returns a map of Event objects to Set objects,
where each Event object is the last level of back-off
of the probability structure for right-side subcat generation and the
set contains all possible Subcat objects for that
most-general context. |
ProbabilityStructure |
rightSubcatProbStructure()
The probability structure for the submodel that generates subcats on the right-hand side of head constituents. |
protected void |
setModelCollection(String mcFilename)
Sets the model collection from the specified filename, which should be the path to a Java object file. |
Map |
simpleModNonterminalMap()
A map from unlexicalized parent-head-side triples to all possible partially-lexicalized modifying nonterminals. |
double |
testProb()
Returns 1.0. |
void |
update(Map<String,String> changedSettings)
Invoked by this class to notify the requesting class that one or more settings have changed. |
Methods inherited from class danbikel.switchboard.AbstractServer |
---|
acceptClientsOnlyByRequest, disableHttp, maxClients, register, reRegister, setPolicyFile, setPolicyFile |
Methods inherited from class danbikel.switchboard.AbstractSwitchboardUser |
---|
alive, cleanup, 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.Server |
---|
acceptClientsOnlyByRequest, id, maxClients |
Methods inherited from interface danbikel.switchboard.SwitchboardUser |
---|
alive, die, host |
Field Detail |
---|
protected ModelCollection modelCollection
protected Word stopWord
Training.stopSym()
, cached here for convenience.
protected int unknownWordThreshold
Settings.unknownWordThreshold
.
protected boolean downcaseWords
Settings.downcaseWords
.
Constructor Detail |
---|
public DecoderServer(String mcFilename) throws ClassNotFoundException, IOException, OptionalDataException
DecoderServer
object.
ClassNotFoundException
IOException
OptionalDataException
public DecoderServer(int timeout) throws RemoteException
timeout
- the timeout value, in milliseconds, to be used for the
client- and server-side RMI sockets of this object
RemoteException
public DecoderServer(int timeout, int port) throws RemoteException
timeout
- the timeout value, in milliseconds, to be used for the
client- and server-side RMI sockets of this objectport
- the port on which to receive RMI calls
RemoteException
public DecoderServer(int maxClients, boolean acceptClientsOnlyByRequest, int timeout, int port) throws RemoteException
maxClients
- the maximum number of clients this server is
willing to acceptacceptClientsOnlyByRequest
- if true
, then
this server will only accept clients that request it specificallytimeout
- the timeout value, in milliseconds, to be used for the
client- and server-side RMI sockets of this objectport
- the port on which to receive RMI calls
RemoteException
public DecoderServer(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException
port
- the port on which to receive RMI callscsf
- the factory from which to create client-side RMI socketsssf
- the factory from which to create server-side RMI sockets
RemoteException
public DecoderServer(int maxClients, boolean acceptClientsOnlyByRequest, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException
maxClients
- the maximum number of clients this server is
willing to acceptacceptClientsOnlyByRequest
- if true
, then
this server will only accept clients that request it specificallyport
- the port on which to receive RMI callscsf
- the factory from which to create client-side RMI socketsssf
- the factory from which to create server-side RMI sockets
RemoteException
Method Detail |
---|
protected void setModelCollection(String mcFilename) throws ClassNotFoundException, IOException, OptionalDataException
ClassNotFoundException
IOException
OptionalDataException
public String getModelCacheStats()
ModelCollection.getModelCacheStats()
.
ModelCollection.getModelCacheStats()
public Sexp convertUnknownWord(Symbol originalWord, int index) throws RemoteException
DecoderServerRemote
DecoderServerRemote.convertUnknownWords(SexpList)
.
convertUnknownWord
in interface DecoderServerRemote
originalWord
- the original word to be (potentially) convertedindex
- the index of the specified word
DecoderServerRemote.convertUnknownWords(SexpList)
, or, if the
specified word is not unknown, then it is returned untouched
RemoteException
public SexpList convertUnknownWords(SexpList sentence) throws RemoteException
WordFeatures.features(Symbol,boolean)
, and
the third element is Constants.trueSym
if this word was never
observed during training or Constants.falseSym
if it was
observed at least once during training.
convertUnknownWords
in interface DecoderServerRemote
sentence
- a list of symbols representing a sentence to be parsed
RemoteException
public CountsTable nonterminals() throws RemoteException
CountsTable
of the internal
ModelCollection
object. The set of nonterminals
is needed when decoding.
nonterminals
in interface DecoderServerRemote
RemoteException
public Map posMap() throws RemoteException
ModelCollection
object. This map
is needed when decoding.
posMap
in interface DecoderServerRemote
RemoteException
public Map headToParentMap() throws RemoteException
DecoderServerRemote
Symbol
obects, and the values are
Set
objects containing Symbol
objects.
headToParentMap
in interface DecoderServerRemote
RemoteException
public Map leftSubcatMap() throws RemoteException
Event
objects to Set
objects,
where each Event
object is the last level of back-off
of the probability structure for left-side subcat generation and the
set contains all possible Subcat
objects for that
most-general context.
leftSubcatMap
in interface DecoderServerRemote
RemoteException
public Map rightSubcatMap() throws RemoteException
Event
objects to Set
objects,
where each Event
object is the last level of back-off
of the probability structure for right-side subcat generation and the
set contains all possible Subcat
objects for that
most-general context.
rightSubcatMap
in interface DecoderServerRemote
RemoteException
public Map modNonterminalMap() throws RemoteException
DecoderServerRemote
Event
, and the values are Set
instances containing Event
objects.
modNonterminalMap
in interface DecoderServerRemote
RemoteException
public Map simpleModNonterminalMap() throws RemoteException
DecoderServerRemote
DecoderServerRemote.modNonterminalMap()
.
The keys are SexpList
objects containing exactly three
Symbol
elements representing the following in a production:
Constants.LEFT
or
Constants.RIGHT
.
Set
objects containing SexpList
objects that contain exactly two Symbol
elements representing a
partially-lexicalized modifying nonterminal:
NP(NNP)
, which is a noun phrase headed by a singular
proper noun.
simpleModNonterminalMap
in interface DecoderServerRemote
RemoteException
Settings.useSimpleModNonterminalMap
public Set prunedPreterms() throws RemoteException
DecoderServerRemote
Sexp
objects representing preterminals that were
pruned during training.
prunedPreterms
in interface DecoderServerRemote
Sexp
objects representing preterminals that were
pruned during training.
RemoteException
Training.prune(Sexp)
,
Treebank.isPreterminal(Sexp)
public Set prunedPunctuation() throws RemoteException
DecoderServerRemote
Sexp
objects) that were
punctuation elements that were “raised away” because they were
either at the beginning or end of a sentence.
prunedPunctuation
in interface DecoderServerRemote
RemoteException
Training.raisePunctuation(Sexp)
,
Treebank.isPuncToRaise(Sexp)
public ProbabilityStructure leftSubcatProbStructure() throws RemoteException
leftSubcatMap()
.
leftSubcatProbStructure
in interface DecoderServerRemote
RemoteException
public ProbabilityStructure rightSubcatProbStructure() throws RemoteException
rightSubcatMap()
.
rightSubcatProbStructure
in interface DecoderServerRemote
RemoteException
public ProbabilityStructure modNonterminalProbStructure() throws RemoteException
modNonterminalMap()
.
modNonterminalProbStructure
in interface DecoderServerRemote
RemoteException
public double testProb() throws RemoteException
testProb
in interface DecoderServerRemote
RemoteException
public double logPrior(int id, TrainerEvent event)
TrainerEvent
, which should be an instance of
HeadEvent
. The prior probability is decomposed into two
parts:p(w,t) * p(N | w,t)where N is a nonterminal label, w is a word and t is a part-of-speech tag.
logPrior
in interface DecoderServerRemote
public double logProbHeadWithSubcats(int id, TrainerEvent event)
DecoderServerRemote
logProbHeadWithSubcats
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
public double logProbHead(int id, TrainerEvent event)
DecoderServerRemote
TrainerEvent
object).
logProbHead
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
public double logProbLeftSubcat(int id, TrainerEvent event)
DecoderServerRemote
TrainerEvent
object).
logProbLeftSubcat
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
public double logProbRightSubcat(int id, TrainerEvent event)
DecoderServerRemote
TrainerEvent
object).
logProbRightSubcat
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
public double logProbSubcat(int id, TrainerEvent event, boolean side)
DecoderServerRemote
DecoderServerRemote.logProbLeftSubcat(int, TrainerEvent)
or
DecoderServerRemote.logProbRightSubcat(int, TrainerEvent)
depending on the value
of side
.
logProbSubcat
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probabilityside
- either Constants.LEFT
or Constants.RIGHT
DecoderServerRemote.logProbLeftSubcat(int, TrainerEvent)
or
DecoderServerRemote.logProbRightSubcat(int, TrainerEvent)
public double logProbTop(int id, TrainerEvent event)
DecoderServerRemote
logProbTop
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
public double logProbMod(int id, TrainerEvent event)
DecoderServerRemote
logProbMod
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
public double logProbModNT(int id, TrainerEvent event)
DecoderServerRemote
logProbModNT
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
public double logProbGap(int id, TrainerEvent event)
DecoderServerRemote
logProbGap
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
public double probHead(int id, TrainerEvent event) throws RemoteException
DecoderServerRemote
TrainerEvent
object).
N.B.: This method is unsupported when Settings.precomputeProbs
is true
.
probHead
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
RemoteException
public double probMod(int id, TrainerEvent event) throws RemoteException
DecoderServerRemote
Settings.precomputeProbs
is true
.
probMod
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
RemoteException
public double probLeftSubcat(int id, TrainerEvent event) throws RemoteException
DecoderServerRemote
TrainerEvent
object).
N.B.: This method is unsupported when Settings.precomputeProbs
is true
.
probLeftSubcat
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
RemoteException
public double probRightSubcat(int id, TrainerEvent event) throws RemoteException
DecoderServerRemote
TrainerEvent
object).
N.B.: This method is unsupported when Settings.precomputeProbs
is true
.
probRightSubcat
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
RemoteException
public double probTop(int id, TrainerEvent event) throws RemoteException
DecoderServerRemote
Settings.precomputeProbs
is true
.
probTop
in interface DecoderServerRemote
id
- the unique id of the client invoking the methodevent
- the top-level TrainerEvent
, containing the
complete context needed to compute the requested probability
RemoteException
protected static int getTimeout()
Settings
.
Settings.sbUserTimeout
public static void main(String[] args)
public void update(Map<String,String> changedSettings)
Settings.Change
update
in interface Settings.Change
changedSettings
- the keys of this map are the settings that have
changed since the last time this method was
invoked, and the values are the old values for
those changed settingsSettings.register(Class,Settings.Change,Set)
,
Settings.register(Settings.Change)
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |