geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/scoring/CountryProximityScorer.java [186:215]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Map<String, Double> scoreMap = new HashMap<>();
    if (distanceMap.isEmpty()) {
      return scoreMap;
    }
    TreeSet<Integer> all = new TreeSet<>();
    for (String key : distanceMap.keySet()) {
      all.addAll(distanceMap.get(key));
    }

    // get min max for normalization, this could be more efficient
    int min = all.first();
    int max = all.last();
    if (min == max) {
      min = 0;
    }

    for (String key : distanceMap.keySet()) {
      TreeSet<Double> normalizedDistances = new TreeSet<>();
      for (Integer i : distanceMap.get(key)) {
        Double norm = normalize(i, min, max);
        //reverse the normed distance so low numbers (closer) are better
        //this could be improved with a "decaying " function using an increasing negative exponent
        Double reverse = Math.abs(norm - 1);
        normalizedDistances.add(reverse);
      }

      List<Double> doubles = new ArrayList<>(normalizedDistances);
      scoreMap.put(key, slidingDistanceAverage(doubles));
    }
    return scoreMap;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/scoring/ProvinceProximityScorer.java [210:239]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Map<String, Double> scoreMap = new HashMap<>();
    if (distanceMap.isEmpty()) {
      return scoreMap;
    }
    TreeSet<Integer> all = new TreeSet<>();
    for (String key : distanceMap.keySet()) {
      all.addAll(distanceMap.get(key));
    }
    
    // get min max for normalization, this could be more efficient
    int min = all.first();
    int max = all.last();
    if (min == max) {
      min = 0;
    }

    for (String key : distanceMap.keySet()) {
      TreeSet<Double> normalizedDistances = new TreeSet<>();
      for (Integer i : distanceMap.get(key)) {
        Double norm = normalize(i, min, max);
        //reverse the normed distance so low numbers (closer) are better
        //this could be improved with a "decaying " function using an increasing negative exponent
        Double reverse = Math.abs(norm - 1);
        normalizedDistances.add(reverse);
      }

      List<Double> doubles = new ArrayList<>(normalizedDistances);
      scoreMap.put(key, slidingDistanceAverage(doubles));
    }
    return scoreMap;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



