|
Parsing Engine | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanbikel.parser.Model
danbikel.parser.JointModel
public class JointModel
Provides a mechanism for grouping related Model objects in order
to estimate the probability of some joint event. A probability estimate
delivered by this class is the product of all the individually-smoothed
probability estimates delivered by this class and all its contained
Model objects. Crucially, this means that this class and all
contained Model objects must be coherent, in the sense
that all internal estimates of the elements of a joint event will be derived
from the same TrainerEvent object. Typically, this class will
provide the means to estimate a joint event via the chain rule, where it is
desirable that all the separate estimates comprising the product be
independently smoothed.
Model
instance, by simply having the ProbabilityStructure.getFuture(danbikel.parser.TrainerEvent, int) method
return an event that is a collection of elements (for example, a nonterminal
symbol and a part-of-speech tag symbol). The crucial feature enabled by this
class is to have the probability estimates for each element of a joint event
to be smoothed individually.
Implementation note: An instance of this class (itself an instance of
Model) will contain an internal collection of other
Model objects whose probability structures are determined via
the ProbabilityStructure.jointModel() method. The internal
Model objects used by this class can be accessed via the getModel(int) method. Note that any of these internal Model
instances may actually also be JointModel instances (although
for efficiency reasons, such a structure should be avoided in general, if
possible).
ProbabilityStructure.jointModel(),
Serialized Form| Field Summary | |
|---|---|
protected int |
numOtherModels
|
protected Model[] |
otherModels
|
| Constructor Summary | |
|---|---|
JointModel(ProbabilityStructure structure)
|
|
| Method Summary | |
|---|---|
void |
canonicalize(FlexibleMap map)
Canonicalizes the objects of this Model, as well as all
internal Model instances. |
void |
deriveCounts(CountsTable trainerCounts,
Filter filter,
double threshold,
FlexibleMap canonical)
Derives counts for this Model, as well as for all
internal Model instances. |
void |
deriveCounts(CountsTable trainerCounts,
Filter filter,
double threshold,
FlexibleMap canonical,
boolean deriveOtherModelCounts)
Derives counts for this Model and optionally for
all internal Model instances. |
double |
estimateLogProb(int id,
TrainerEvent event)
Estimates a conditional probability in log-space from the specified maximal-context trainer event. |
double |
estimateNonJointLogProb(int id,
TrainerEvent event)
Estimates the log-probability of the specified event under this Model without adding the log-probabilities of the internal Model
objects. |
double |
estimateNonJointProb(int id,
TrainerEvent event)
Estimates the probability of the specified event under this Model
without multiplying the probabilities of the internal Model
objects. |
double |
estimateProb(int id,
TrainerEvent event)
Estimates a conditional probability from the specified maximal-context trainer event. |
String |
getCacheStats()
Returns a string representing the cache statistics for this and all other, internal Model objects. |
Model |
getModel(int idx)
Returns this or any of the internal Model instances used
to produce joint probability estimates. |
ProbabilityStructure |
getProbStructure()
Returns the primary probability structure of this joint model, which is that used by this Model instance (as opposed to one of the
internal Model instances). |
ProbabilityStructure |
getProbStructure(int idx)
Returns a probability structure of this joint model, which is either that used by this Model instance, or a structure used by
one of the internal Model instances. |
int |
numModels()
Returns the number of models used to produce a joint probability estimate, including this Model instance. |
void |
precomputeProbs()
Precomputes probabilities and smoothing values for this Model
and for all internal Model instances. |
void |
setCanonicalEvents(FlexibleMap canonical)
Sets the Model.canonicalEvents member of this object to be the
specified FlexibleMap, as well as setting the same member
of all internal Model objects. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int numOtherModels
protected Model[] otherModels
| Constructor Detail |
|---|
public JointModel(ProbabilityStructure structure)
| Method Detail |
|---|
public void canonicalize(FlexibleMap map)
Model, as well as all
internal Model instances.
canonicalize in class Modelmap - the map to be used for canonicalizationpublic void setCanonicalEvents(FlexibleMap canonical)
Model.canonicalEvents member of this object to be the
specified FlexibleMap, as well as setting the same member
of all internal Model objects.
setCanonicalEvents in class Modelcanonical - the reflexive map of canonical Event
objectsModelCollection.internalReadObject(java.io.ObjectInputStream)
public void deriveCounts(CountsTable trainerCounts,
Filter filter,
double threshold,
FlexibleMap canonical)
Model, as well as for all
internal Model instances.
deriveCounts in class ModeltrainerCounts - a map from TrainerEvent objects to
their counts (as doubles) from which to derive countsfilter - used to filter out TrainerEvent objects
whose derived counts should not be derived for this modelthreshold - a (currently unused) count cut-off thresholdcanonical - a reflexive map used to canonicalize objects
created when deriving counts
public void deriveCounts(CountsTable trainerCounts,
Filter filter,
double threshold,
FlexibleMap canonical,
boolean deriveOtherModelCounts)
Model and optionally for
all internal Model instances.
deriveCounts in class ModeltrainerCounts - a map from TrainerEvent objects to
their counts (as doubles) from which to derive countsfilter - used to filter out TrainerEvent objects
whose derived counts should not be derived for this modelthreshold - a (currently unused) count cut-off thresholdcanonical - a reflexive map used to canonicalize objects
created when deriving countsderiveOtherModelCounts - indicates whether to derive
counts for the internal Model instances contained
in this joint modelpublic void precomputeProbs()
Model
and for all internal Model instances.
precomputeProbs in class ModelprecomputeProbs(MapToPrimitive.Entry, ...),
storePrecomputedProbs
public double estimateLogProb(int id,
TrainerEvent event)
Model instances.
estimateLogProb in class Modelid - the id of the decoding client calling this methodevent - the maximal-context event from which to produce a
conditional probability estimate of some element(s) of that
context
public double estimateNonJointLogProb(int id,
TrainerEvent event)
Model without adding the log-probabilities of the internal Model
objects.
id - the id of the caller requesting the log-probabilityevent - the event containing the history context and future from which
to estimate a conditional log-probability
Model
without adding the log-probabilities of the internal Model
objects
public double estimateProb(int id,
TrainerEvent event)
Model instances.
estimateProb in class Modelid - the id of the decoding client calling this methodevent - the maximal-context event from which to derive a
conditional probability estimate
public double estimateNonJointProb(int id,
TrainerEvent event)
Model
without multiplying the probabilities of the internal Model
objects.
id - the id of the caller requesting the probabilityevent - the event containing the history context and future from which
to estimate a conditional probability
Model
without multiplying the probabilities of the internal Model
objectspublic int numModels()
Model instance.
numModels in class ModelModel instance.public Model getModel(int idx)
Model instances used
to produce joint probability estimates.
getModel in class Modelidx - the index of the Model to return
Model at the specified index; if the specified
index is 0, then this Model instance is returned;
otherwise, one of the internal Model instances is returned
ArrayIndexOutOfBoundsException - if the specified index is
greater than numModels() - 1public ProbabilityStructure getProbStructure()
Model instance (as opposed to one of the
internal Model instances).
getProbStructure in class ModelModel instancepublic ProbabilityStructure getProbStructure(int idx)
Model instance, or a structure used by
one of the internal Model instances.
idx - the index of the probability structure to return
Model instance is returned; otherwise,
the probability structure of one of the internal Model
instances is returned
ArrayIndexOutOfBoundsException - if the specified index is
greater than numModels() - 1public String getCacheStats()
Model objects.
getCacheStats in class ModelModel objects.
|
Parsing Engine | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||