if (!trainFile.haveReadFile)
trainFile.readFile();
if (trainFile.chunks.size() == 0)
throw new ParserException(trainFile.filename, "No chunks found");
trainFile = (FeatFile) trainFile.clone();
trainFile.normalizeFeatures();
trainFile.applyFeatureWeights();
// To change the number of beats per state all we have to do
// is modify the chunks in trainFile by joining every
// beatsPerCodeword chunk into one a superchunk.
Vector newChunks = new Vector();
for (int x = 0; x < trainFile.chunks.size() - beatsPerCodeword + 1; x += beatsPerCodeword)
{
FeatChunk newChunk = (FeatChunk) ((FeatChunk) trainFile.chunks
.get(x)).clone();
// double length = 0;
for (int y = 1; y < beatsPerCodeword; y++)
{
FeatChunk f = (FeatChunk) trainFile.chunks.get(x + y);
newChunk.addFeature(f.getFeatures());
newChunk.length += f.length;
}
newChunks.add(newChunk);
}
trainFile.chunks = newChunks;
progress.setMaximum(trainFile.chunks.size());
if (featsToQuantize != null)
{
if (!featsToQuantize.haveReadFile)
featsToQuantize.readFile();
// What if features don't match
if (!featsToQuantize.isCompatibleWith(trainFile))
throw new ParserException(trainFile.filename,
"Features do not match those in "
+ featsToQuantize.filename);
featsToQuantize = (FeatFile) featsToQuantize.clone();
featsToQuantize.normalizeFeatures();