|
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.decoderUseLocalProbabilityCache
protected int numAccesses
protected int numHits
Constructor Detail |
---|
public CachingDecoderServer(DecoderServerRemote stub)
stub
- the stub to use for flow-through callsMethod 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 cachedpublic int id() throws RemoteException
DecoderServerRemote
instance.
id
in interface Server
id
in interface SwitchboardUser
DecoderServerRemote
instance.
RemoteException
public boolean acceptClientsOnlyByRequest() throws RemoteException
Server
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.
acceptClientsOnlyByRequest
in interface Server
RemoteException
SwitchboardRemote.register(Server)
,
SwitchboardRemote.getServer(int,int)
public int maxClients() throws RemoteException
Server
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). 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 Server
RemoteException
SwitchboardRemote.register(Server)
public boolean alive() throws RemoteException
SwitchboardUser
false
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 SwitchboardUser
RemoteException
AbstractSwitchboardUser
public void die(boolean now) throws RemoteException
SwitchboardUser
now
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 SwitchboardUser
now
- 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 SwitchboardUser
RemoteException
public Map posMap() throws RemoteException
DecoderServerRemote
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
DecoderServerRemote
Event
objects, and the values are
Set
objects containing Subcat
objects.
leftSubcatMap
in interface DecoderServerRemote
RemoteException
public Map rightSubcatMap() throws RemoteException
DecoderServerRemote
Event
objects, and the values are
Set
objects containing Subcat
objects.
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 CountsTable nonterminals() throws RemoteException
DecoderServerRemote
nonterminals
in interface DecoderServerRemote
RemoteException
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 Sexp convertUnknownWord(Symbol originalWord, int index) throws RemoteException
convertUnknownWords(SexpList)
.
convertUnknownWord
in interface DecoderServerRemote
originalWord
- 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 DecoderServerRemote
sentence
- a list of symbols representing a sentence to be parsed
RemoteException
public ProbabilityStructure leftSubcatProbStructure() throws RemoteException
DecoderServerRemote
DecoderServerRemote.leftSubcatMap()
.
leftSubcatProbStructure
in interface DecoderServerRemote
RemoteException
public ProbabilityStructure rightSubcatProbStructure() throws RemoteException
DecoderServerRemote
DecoderServerRemote.rightSubcatMap()
.
rightSubcatProbStructure
in interface DecoderServerRemote
RemoteException
public ProbabilityStructure modNonterminalProbStructure() throws RemoteException
DecoderServerRemote
DecoderServerRemote.modNonterminalMap()
.
modNonterminalProbStructure
in interface DecoderServerRemote
RemoteException
public double testProb() throws RemoteException
testProb
in interface DecoderServerRemote
RemoteException
public double logPrior(int id, TrainerEvent event) throws RemoteException
HeadEvent
.
logPrior
in interface DecoderServerRemote
RemoteException
public double logProbHeadWithSubcats(int id, TrainerEvent event) throws RemoteException
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
RemoteException
public double logProbHead(int id, TrainerEvent event) throws RemoteException
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
RemoteException
public double logProbLeftSubcat(int id, TrainerEvent event) throws RemoteException
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
RemoteException
public double logProbRightSubcat(int id, TrainerEvent event) throws RemoteException
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
RemoteException
public double logProbSubcat(int id, TrainerEvent event, boolean side) throws RemoteException
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)
RemoteException
public double logProbTop(int id, TrainerEvent event) throws RemoteException
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
RemoteException
public double logProbMod(int id, TrainerEvent event) throws RemoteException
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
RemoteException
public double logProbModNT(int id, TrainerEvent event) throws RemoteException
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
RemoteException
public double logProbGap(int id, TrainerEvent event) throws RemoteException
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
RemoteException
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
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |