public static void main(String[] args) throws Exception {
		Options app = new Options();
		CmdLineParser parser = new CmdLineParser(Discretizer.class, app);
		try {
			parser.parse(args);
			if (app.maxNumBins < 0) {
				throw new IllegalArgumentException();
			}
		} catch (IllegalArgumentException e) {
			parser.printUsage();
			System.exit(1);
		}
		List<Attribute> attributes = null;
		if (app.trainPath != null) {
			Instances trainSet = InstancesReader.read(app.attPath, app.trainPath);
			attributes = trainSet.getAttributes();
			for (int i = 0; i < attributes.size(); i++) {
				Attribute attribute = attributes.get(i);
				if (attribute.getType() == Type.NUMERIC) {
					// Only discretize numeric attributes
					Discretizer.discretize(trainSet, i, app.maxNumBins);
				}
			}
		} else if (app.disAttPath != null) {
			attributes = AttributesReader.read(app.disAttPath).v1;
		} else {
			parser.printUsage();
			System.exit(1);
		}

		Instances instances = InstancesReader.read(app.attPath, app.inputPath);
		List<Attribute> attrs = instances.getAttributes();
		for (int i = 0; i < attrs.size(); i++) {
			Attribute attr = attrs.get(i);
			if (attr.getType() == Type.NUMERIC) {
				BinnedAttribute binnedAttr = (BinnedAttribute) attributes.get(i);
				// Only discretize numeric attributes
				Discretizer.discretize(instances, i, binnedAttr.getBins());
			}
		}

		if (app.outputAttPath != null) {
			InstancesWriter.write(instances, app.outputAttPath, app.outputPath);
		} else {
			InstancesWriter.write(instances, app.outputPath);
		}
	}