// Computes the intermediate structural similarity between two terms by
 // checking for mappings between all their ancestors
 private double mapTwoTerms(int sId, int tId) {
   if (!source.isClass(sId) || !target.isClass(tId)) return 0.0;
   Set<Integer> sourceParents = rels.getSuperClasses(sId, true);
   Set<Integer> targetParents = rels.getSuperClasses(tId, true);
   double sim = 0.0;
   for (Integer i : sourceParents)
     for (Integer j : targetParents) sim += input.getSimilarity(i, j);
   return sim / Math.min(sourceParents.size(), targetParents.size());
 }
 /**
  * Computes and returns the language setting of the matching problem based on the language overlap
  * between the input ontologies
  */
 public static LanguageSetting getLanguageSetting() {
   Ontology source = AML.getInstance().getSource();
   Ontology target = AML.getInstance().getTarget();
   HashMap<String, Integer> sLangs = new HashMap<String, Integer>();
   int sTotal = 0;
   double sMax = 0.0;
   String sLang = "";
   for (String l : source.getLexicon().getLanguages()) {
     if (!l.equals("Formula")) {
       int count = source.getLexicon().getLanguageCount(l);
       sLangs.put(l, count);
       sTotal += count;
       if (count > sMax) {
         sMax = count;
         sLang = l;
       }
     }
   }
   sMax /= sTotal;
   // Do the same for the target ontology
   HashMap<String, Integer> tLangs = new HashMap<String, Integer>();
   int tTotal = 0;
   double tMax = 0.0;
   String tLang = "";
   for (String l : target.getLexicon().getLanguages()) {
     if (!l.equals("Formula")) {
       int count = target.getLexicon().getLanguageCount(l);
       tLangs.put(l, count);
       tTotal += count;
       if (count > tMax) {
         tMax = count;
         tLang = l;
       }
     }
   }
   tMax /= (1.0 * tTotal);
   // If both ontologies have the same main language, setting is single language
   if (sLang.equals(tLang) && sMax > 0.8 && tMax > 0.8) return SINGLE;
   // If the main language of each ontology is not present in the other, setting is translate
   else if (!sLangs.containsKey(tLang) && !tLangs.containsKey(sLang)) return TRANSLATE;
   // Otherwise, setting is multi-language
   else return MULTI;
 }