options.parseOptions(args);
LoggerUtil.setLevel(Level.FINE);
int dimensions = options.getIntOption('r');
MatrixFactorization reducer = null;
Format format = null;
if (options.getStringOption('a').equals("NMF")) {
reducer = new NonNegativeMatrixFactorizationMultiplicative();
format = Format.MATLAB_SPARSE;
} else if (options.getStringOption('a').equals("SVD")) {
reducer = SVD.getFastestAvailableFactorization();
format = Format.SVDLIBC_SPARSE_BINARY;
} else
System.exit(1);
MatrixFile mFile = new MatrixFile(new File(options.getPositionalArg(0)),
format);
reducer.factorize(mFile, dimensions);
File wordSpaceFile = new File(options.getStringOption('w'));
MatrixIO.writeMatrix(reducer.dataClasses(), wordSpaceFile,
Format.DENSE_TEXT);
File docSpaceFile = new File(options.getStringOption('d'));
MatrixIO.writeMatrix(reducer.classFeatures(), docSpaceFile,
Format.DENSE_TEXT);
}