String outFile = conf.get(Constants.OutputPath);
String translateOnly = conf.get(Constants.TranslateOnly);
if (translateOnly != null) {
ResultWriter resultWriter = new ResultWriter((outFile == null ? "translations." + runName + ".txt" : outFile), false, fs);
for (String qid : queries.keySet()) {
String query = queries.get(qid);
if (grammarPaths != null) {
String grammarPath = grammarPaths.get(qid);
conf.set(Constants.GrammarPath, grammarPath);
}
long start = System.currentTimeMillis();
StructuredQuery structuredQuery = generator.parseQuery(query, fs, conf);
long end = System.currentTimeMillis();
LOG.info("Generating " + qid + ": " + ( end - start) + "ms");
generateTime += ( end - start ) ;
LOG.info("<Processed>:::" + runName + ":::" + qid + ":::" + structuredQuery.getQuery());
printResults(qid, runName, structuredQuery, resultWriter, translateOnly.equals(Constants.Indri));
}
resultWriter.flush();
LOG.info("<TIME>:::" + runName + ":::" + generateTime + ":::" + rankTime);
} else {
ResultWriter resultWriter = new ResultWriter((outFile == null ? "ranking." + runName + ".txt" : outFile), false, fs);
for ( String qid : queries.keySet()) {
String query = queries.get(qid);
if (grammarPaths != null) {
String grammarPath = grammarPaths.get(qid);
conf.set(Constants.GrammarPath, grammarPath);
}
long start = System.currentTimeMillis();
StructuredQuery structuredQuery = generator.parseQuery(query, fs, conf);
long end = System.currentTimeMillis();
LOG.info("Generating " + qid + ": " + ( end - start) + "ms");
generateTime += ( end - start ) ;
LOG.info("<Processed>:::" + runName + ":::" + qid + ":::" + structuredQuery.getQuery());
start = System.currentTimeMillis();
ranker.rank(qid, structuredQuery.getQuery(), structuredQuery.getQueryLength());
end = System.currentTimeMillis();
LOG.info("Ranking " + qid + ": " + ( end - start) + "ms");
rankTime += ( end - start ) ;
printResults(qid, runName, ranker, resultWriter);
// save allResults
allResults.put(runName, getResults());
}
resultWriter.flush();
LOG.info("<TIME>:::" + runName + ":::" + generateTime + ":::" + rankTime);
}
} catch (IOException e) {
e.printStackTrace();
}