private SimilarityMetric createLinkSimilarity(String name)
     throws ConfigurationException, IOException {
   JSONObject params = configuration.getMetric(name);
   SimilarityMetric metric;
   String field = requireString(params, "field");
   LinkSimilarity lmetric =
       new LinkSimilarity(
           loadMainMapper(),
           loadIndex(requireString(params, "lucene")),
           env.getMainIndex(),
           field);
   if (params.containsKey("similarity")) {
     String sim = requireString(params, "similarity");
     if (sim.equals("tfidf")) {
       lmetric.setSimilarity(LinkSimilarity.SimFn.TFIDF);
     } else if (sim.equals("google")) {
       lmetric.setSimilarity(LinkSimilarity.SimFn.GOOGLE);
     } else if (sim.equals("logodds")) {
       lmetric.setSimilarity(LinkSimilarity.SimFn.LOGODDS);
     } else if (sim.equals("jacard")) {
       lmetric.setSimilarity(LinkSimilarity.SimFn.JACARD);
     } else if (sim.equals("lucene")) {
       lmetric.setSimilarity(LinkSimilarity.SimFn.LUCENE);
     } else {
       throw new IllegalArgumentException("unknown similarity: " + sim);
     }
   }
   if (params.containsKey("minDocFreq")) {
     lmetric.setMinDocFreq(requireInteger(params, "minDocFreq"));
   }
   metric = lmetric;
   return metric;
 }
 private SimilarityMetric loadEnsembleMetric(String key)
     throws IOException, ConfigurationException {
   info("loading ensemble metric " + key);
   Map<String, Object> params = (Map<String, Object>) configuration.getMetric(key);
   setDoEnsembles(false);
   List<SimilarityMetric> metrics = loadMetrics();
   EnsembleSimilarity similarity =
       new EnsembleSimilarity(new SvmEnsemble(), loadMainMapper(), env.getMainIndex());
   similarity.setComponents(metrics);
   similarity.read(requireDirectory(params, "model"));
   similarity.setName(key);
   if (params.containsKey("minComponents")) {
     similarity.setMinComponents(requireInteger(params, "minComponents"));
   }
   return similarity;
 }