public Map appyMajorRule()

in core/src/main/java/org/apache/sdap/mudrod/integration/LinkageIntegration.java [101:135]


  public Map<String, Double> appyMajorRule(String input) {
    termList = new ArrayList<>();
    Map<String, Double> termsMap = new HashMap<>();
    Map<String, List<LinkedTerm>> map = new HashMap<>();
    try {
      map = aggregateRelatedTermsFromAllmodel(es.customAnalyzing(props.getProperty(INDEX_NAME), input));
    } catch (InterruptedException | ExecutionException e) {
      LOG.error("Error applying majority rule", e);
      if (e instanceof InterruptedException) {
        Thread.currentThread().interrupt();
      }
    }

    for (Entry<String, List<LinkedTerm>> entry : map.entrySet()) {
      List<LinkedTerm> list = entry.getValue();
      double sumModelWeight = 0;
      double tmp = 0;
      for (LinkedTerm element : list) {
        sumModelWeight += getModelweight(element.model);

        if (element.weight > tmp) {
          tmp = element.weight;
        }
      }

      double finalWeight = tmp + ((sumModelWeight - 2) * 0.05);
      
      if (finalWeight < 0) finalWeight = 0;
      if (finalWeight > 1) finalWeight = 1;
      
      termsMap.put(entry.getKey(), Double.parseDouble(df.format(finalWeight)));
    }

    return sortMapByValue(termsMap);
  }