IndexReader reader = IndexReader.open(dir, true);
Weight weight;
if (cmdLine.hasOption(weightOpt)) {
String wString = cmdLine.getValue(weightOpt).toString();
if (wString.equalsIgnoreCase("tf")) {
weight = new TF();
} else if (wString.equalsIgnoreCase("tfidf")) {
weight = new TFIDF();
} else {
throw new OptionException(weightOpt);
}