throw new UnsupportedOperationException ("Training with multiple sets not supported.");
}
trainingGatheredFor = training;
for (int i = 0; i < training.size(); i++) {
Instance instance = training.get(i);
FeatureVectorSequence input = (FeatureVectorSequence) instance.getData();
FeatureSequence output = (FeatureSequence) instance.getTarget();
// Do it for the paths consistent with the labels...
new SumLatticeDefault (memm, input, output, new Transducer.Incrementor() {
public void incrementFinalState(Transducer.State s, double count) { }
public void incrementInitialState(Transducer.State s, double count) { }
public void incrementTransition(Transducer.TransitionIterator ti, double count) {
MEMM.State source = (MEMM.State) ti.getSourceState();
if (count != 0) {
// Create the source state's trainingSet if it doesn't exist yet.
if (source.trainingSet == null)
// New InstanceList with a null pipe, because it doesn't do any processing of input.
source.trainingSet = new InstanceList (null);
// TODO We should make sure we don't add duplicates (through a second call to setWeightsDimenstion..!
// TODO Note that when the training data still allows ambiguous outgoing transitions
// this will add the same FV more than once to the source state's trainingSet, each
// with >1.0 weight. Not incorrect, but inefficient.
// System.out.println ("From: "+source.getName()+" ---> "+getOutput()+" : "+getInput());
source.trainingSet.add (new Instance(ti.getInput (), ti.getOutput (), null, null), count);
}
}
});
}
}