private SimilarityMetric createEsaSimilarity(String name)
     throws ConfigurationException, IOException {
   JSONObject params = configuration.getMetric(name);
   ESASimilarity metric =
       new ESASimilarity(loadMainMapper(), loadIndex(requireString(params, "lucene")));
   if (params.containsKey("textLucene")) {
     metric.setTextHelper(loadIndex(requireString(params, "textLucene")));
   }
   return metric;
 }
 public static void main(String args[])
     throws IOException, InterruptedException, CompressorException {
   if (args.length != 4 && args.length != 5) {
     System.err.println(
         "usage: java "
             + TextSimilarity.class.getName()
             + " field lucene-text-index-dir output-file num-results [num-threads]");
   }
   IndexHelper helper = new IndexHelper(new File(args[1]), true);
   ESASimilarity sim = new ESASimilarity(null, helper);
   if (args[0].equals("links")) {
     sim.setMinTermFreq(1); // HACK!
   }
   int cores =
       (args.length == 5) ? Integer.valueOf(args[4]) : Runtime.getRuntime().availableProcessors();
   PairwiseSimilarityWriter writer = new PairwiseSimilarityWriter(sim, new File(args[2]));
   writer.writeSims(helper.getWpIds(), cores, Integer.valueOf(args[3]));
 }