|
Parsing Engine | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanbikel.parser.CachingDecoderServer
public class CachingDecoderServer
A wrapper object for a DecoderServerRemote instance that provides
probability caching. Allmethods that return either probabilities or log
probabilities first check and internal probability cache before requesting a
probability using the DecoderServerRemote instance. Cache size is
determined by the value of the setting Settings.decoderLocalCacheSize.
Settings.decoderLocalCacheSize,
Settings.decoderUseLocalProbabilityCache,
ProbabilityCache| Field Summary | |
|---|---|
protected ProbabilityCache |
cache
The cache used for storing probabilities. |
protected int |
numAccesses
The number of cache accesses over the lifetime of this object. |
protected int |
numHits
The number of cache hits over the lifetime of this object. |
protected DecoderServerRemote |
stub
The stub through which all method invocations on this object will flow. |
| Fields inherited from interface danbikel.switchboard.Server |
|---|
acceptUnlimitedClients |
| Constructor Summary | |
|---|---|
CachingDecoderServer(DecoderServerRemote stub)
Constructs a new instance around the specified stub. |
|
| Method Summary | |
|---|---|
boolean |
acceptClientsOnlyByRequest()
Returns whether this server is only willing to accept clients that request it. |
boolean |
alive()
A simple "ping" method for the switchboard to continually make sure its users are alive. |
Sexp |
convertUnknownWord(Symbol originalWord,
int index)
Returns either the specified word untouched, or a 3-element list as would be created by 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. |
void |
die(boolean now)
Tells the switchboard user to commit suicide. |
Map |
headToParentMap()
A mapping from head labels to possible parent labels. |
String |
host()
Returns the hostname on which this switchboard user is running. |
int |
id()
The unique identifier of this DecoderServerRemote instance. |
Map |
leftSubcatMap()
A mapping from left subcat-prediction conditioning contexts (typically parent and head nonterminal labels) to all possible left subcat frames. |
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 of generating the nonterminal contained in the specified 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. |
int |
maxClients()
The maximum number of clients this server is willing to accept, or Server.acceptUnlimitedClients if this server is willing to accept a
virtually unlimited number of clients (a large maximum value may
be used by 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()
A counts table of unlexicalized nonterminals, i.e., a map of unlexicalized nonterminals to their respective frequencies in the training data. |
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. |
protected void |
putInCache(TrainerEvent key,
double value)
Inserts the specified TrainerEvent and its associated probability
into this object's probability cache. |
Map |
rightSubcatMap()
A mapping from right subcat-prediction conditioning contexts (typically parent and head nonterminal labels) to all possible right subcat frames. |
ProbabilityStructure |
rightSubcatProbStructure()
The probability structure for the submodel that generates subcats on the right-hand side of head constituents. |
Map |
simpleModNonterminalMap()
A map from unlexicalized parent-head-side triples to all possible partially-lexicalized modifying nonterminals. |
double |
testProb()
Returns a test probability (for debugging purposes). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DecoderServerRemote stub
protected ProbabilityCache cache
Settings.decoderLocalCacheSize,
Settings.decoderUseLocalProbabilityCacheprotected int numAccesses
protected int numHits
| Constructor Detail |
|---|
public CachingDecoderServer(DecoderServerRemote stub)
stub - the stub to use for flow-through calls| Method Detail |
|---|
protected void putInCache(TrainerEvent key,
double value)
TrainerEvent and its associated probability
into this object's probability cache.
key - the event whose probability is to be cachedvalue - the probability to be cached
public int id()
throws RemoteException
DecoderServerRemote instance.
id in interface Serverid in interface SwitchboardUserDecoderServerRemote instance.
RemoteException
public boolean acceptClientsOnlyByRequest()
throws RemoteException
ServerNote that a server may change the return value of this method over time; this method is guaranteed to be called and its value cached every time a client is assigned to this server.
acceptClientsOnlyByRequest in interface ServerRemoteExceptionSwitchboardRemote.register(Server),
SwitchboardRemote.getServer(int,int)
public int maxClients()
throws RemoteException
ServerServer.acceptUnlimitedClients if this server is willing to accept a
virtually unlimited number of clients (a large maximum value may
be used by the switchboard). It is an error for this method to
return any number other than a non-zero positive integer or
the special value.
Note that a server may change the return value of this method over time; this method is guaranteed to be called and its value cached every time a client is assigned to this server.
maxClients in interface ServerRemoteExceptionSwitchboardRemote.register(Server)
public boolean alive()
throws RemoteException
SwitchboardUserfalse after invocation of
die(false) to indicate to switchboard that user is
dying safely. However, implementations should also not wait
indefinitely for this last call, instead using an appropriate
maximum timeout value (such as the timeout of the transport
layer, if available) before unexporting themselves.
alive in interface SwitchboardUserRemoteExceptionAbstractSwitchboardUser
public void die(boolean now)
throws RemoteException
SwitchboardUsernow value of false, to allow the
switchboard a final successful call to alive, which
will return false. The switchboard will typically invoke this
method on its users with a now value of
true.
Important synchronization note: This method should be non-blocking. That is, it shouldn't wait for some switchboard resource or information to become available before returning. If this condition is not met, then deadlock could occur.
die in interface SwitchboardUsernow - if false, indicates that this switchboard user
should wait gracefully for a final invocation by the switchboard
of its SwitchboardUser.alive() method, so that it can return false; otherwise,
this method should cause the switchboard user to die as soon as possible
RemoteException
public String host()
throws RemoteException
SwitchboardUser
host in interface SwitchboardUserRemoteException
public Map posMap()
throws RemoteException
DecoderServerRemoteModelCollection object. This map
is needed when decoding.
posMap in interface DecoderServerRemoteRemoteException
public Map headToParentMap()
throws RemoteException
DecoderServerRemoteSymbol obects, and the values are
Set objects containing Symbol objects.
headToParentMap in interface DecoderServerRemoteRemoteException
public Map leftSubcatMap()
throws RemoteException
DecoderServerRemoteEvent objects, and the values are
Set objects containing Subcat objects.
leftSubcatMap in interface DecoderServerRemoteRemoteException
public Map rightSubcatMap()
throws RemoteException
DecoderServerRemoteEvent objects, and the values are
Set objects containing Subcat objects.
rightSubcatMap in interface DecoderServerRemoteRemoteException
public Map modNonterminalMap()
throws RemoteException
DecoderServerRemoteEvent, and the values are Set instances containing Event objects.
modNonterminalMap in interface DecoderServerRemoteRemoteException
public Map simpleModNonterminalMap()
throws RemoteException
DecoderServerRemoteDecoderServerRemote.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 DecoderServerRemoteRemoteExceptionSettings.useSimpleModNonterminalMap
public CountsTable nonterminals()
throws RemoteException
DecoderServerRemote
nonterminals in interface DecoderServerRemoteRemoteException
public Set prunedPreterms()
throws RemoteException
DecoderServerRemoteSexp objects representing preterminals that were
pruned during training.
prunedPreterms in interface DecoderServerRemoteSexp objects representing preterminals that were
pruned during training.
RemoteExceptionTraining.prune(Sexp),
Treebank.isPreterminal(Sexp)
public Set prunedPunctuation()
throws RemoteException
DecoderServerRemoteSexp objects) that were
punctuation elements that were “raised away” because they were
either at the beginning or end of a sentence.
prunedPunctuation in interface DecoderServerRemoteRemoteExceptionTraining.raisePunctuation(Sexp),
Treebank.isPuncToRaise(Sexp)
public Sexp convertUnknownWord(Symbol originalWord,
int index)
throws RemoteException
convertUnknownWords(SexpList).
convertUnknownWord in interface DecoderServerRemoteoriginalWord - the original word to be (potentially) convertedindex - the index of the specified word
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 DecoderServerRemotesentence - a list of symbols representing a sentence to be parsed
RemoteException
public ProbabilityStructure leftSubcatProbStructure()
throws RemoteException
DecoderServerRemoteDecoderServerRemote.leftSubcatMap().
leftSubcatProbStructure in interface DecoderServerRemoteRemoteException
public ProbabilityStructure rightSubcatProbStructure()
throws RemoteException
DecoderServerRemoteDecoderServerRemote.rightSubcatMap().
rightSubcatProbStructure in interface DecoderServerRemoteRemoteException
public ProbabilityStructure modNonterminalProbStructure()
throws RemoteException
DecoderServerRemoteDecoderServerRemote.modNonterminalMap().
modNonterminalProbStructure in interface DecoderServerRemoteRemoteException
public double testProb()
throws RemoteException
testProb in interface DecoderServerRemoteRemoteException
public double logPrior(int id,
TrainerEvent event)
throws RemoteException
HeadEvent.
logPrior in interface DecoderServerRemoteRemoteException
public double logProbHeadWithSubcats(int id,
TrainerEvent event)
throws RemoteException
logProbHeadWithSubcats in interface DecoderServerRemoteid - 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 logProbHead(int id,
TrainerEvent event)
throws RemoteException
DecoderServerRemoteTrainerEvent object).
logProbHead in interface DecoderServerRemoteid - 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 logProbLeftSubcat(int id,
TrainerEvent event)
throws RemoteException
DecoderServerRemoteTrainerEvent
object).
logProbLeftSubcat in interface DecoderServerRemoteid - 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 logProbRightSubcat(int id,
TrainerEvent event)
throws RemoteException
DecoderServerRemoteTrainerEvent
object).
logProbRightSubcat in interface DecoderServerRemoteid - 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 logProbSubcat(int id,
TrainerEvent event,
boolean side)
throws RemoteException
DecoderServerRemoteDecoderServerRemote.logProbLeftSubcat(int, TrainerEvent) or
DecoderServerRemote.logProbRightSubcat(int, TrainerEvent) depending on the value
of side.
logProbSubcat in interface DecoderServerRemoteid - 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)
RemoteException
public double logProbTop(int id,
TrainerEvent event)
throws RemoteException
logProbTop in interface DecoderServerRemoteid - 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 logProbMod(int id,
TrainerEvent event)
throws RemoteException
DecoderServerRemote
logProbMod in interface DecoderServerRemoteid - 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 logProbModNT(int id,
TrainerEvent event)
throws RemoteException
DecoderServerRemote
logProbModNT in interface DecoderServerRemoteid - 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 logProbGap(int id,
TrainerEvent event)
throws RemoteException
logProbGap in interface DecoderServerRemoteid - 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 probHead(int id,
TrainerEvent event)
throws RemoteException
DecoderServerRemoteTrainerEvent object).
N.B.: This method is unsupported when Settings.precomputeProbs is true.
probHead in interface DecoderServerRemoteid - 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
DecoderServerRemoteSettings.precomputeProbs is true.
probMod in interface DecoderServerRemoteid - 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
DecoderServerRemoteTrainerEvent
object).
N.B.: This method is unsupported when Settings.precomputeProbs is true.
probLeftSubcat in interface DecoderServerRemoteid - 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
DecoderServerRemoteTrainerEvent
object).
N.B.: This method is unsupported when Settings.precomputeProbs is true.
probRightSubcat in interface DecoderServerRemoteid - 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
DecoderServerRemoteSettings.precomputeProbs is true.
probTop in interface DecoderServerRemoteid - the unique id of the client invoking the methodevent - the top-level TrainerEvent, containing the
complete context needed to compute the requested probability
RemoteException
|
Parsing Engine | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||