*/
public void run() {
int numLabels = stateLabelMap.getNumLabels();
double[] expectation = new double[numLabels];
int featureCount = 0;
SumLattice lattice = null;
for (int i : lattices.keySet()) {
// skip if the instance doesn't have any constraints
if (!constraintBits.get(i)) {
continue;
}
FeatureVectorSequence fvs = (FeatureVectorSequence) ilist.get(i).getData();
lattice = lattices.get(i);
assert(lattice != null)
: "Lattice is null:: " + i + ", size: " + lattices.size();
// update the number of times this feature occurred in the sequence
// and the label expectations due to this sequence
featureCount += getExpectationForInstance(
fi, fvs, lattice.getGammas(), expectation);
}
assert(!MatrixOps.isNaNOrInfinite(expectation));
if (MatrixOps.isNonZero(expectation)) {
// normalizing label expectations