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();
System.out.println("Generating " + qid + ": " + ( end - start) + "ms");
generateTime += ( end - start ) ;
System.out.println("<Processed>:::" + runName + ":::" + qid + ":::" + structuredQuery.getQuery());
printResults(qid, runName, structuredQuery, resultWriter, translateOnly.equals(Constants.Indri));
}
resultWriter.flush();
System.out.println("<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();
System.out.println("Generating " + qid + ": " + ( end - start) + "ms");
generateTime += ( end - start ) ;
System.out.println("<Processed>:::" + runName + ":::" + qid + ":::" + structuredQuery.getQuery());
start = System.currentTimeMillis();
ranker.rank(qid, structuredQuery.getQuery(), structuredQuery.getQueryLength());
end = System.currentTimeMillis();
System.out.println("Ranking " + qid + ": " + ( end - start) + "ms");
rankTime += ( end - start ) ;
printResults(qid, runName, ranker, resultWriter);
// save allResults
allResults.put(runName, getResults());
}
resultWriter.flush();
System.out.println("<TIME>:::" + runName + ":::" + generateTime + ":::" + rankTime);
}
} catch (IOException e) {
e.printStackTrace();
}