private void loadMaps()

in geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContextGenerator.java [333:374]


  private void loadMaps(List<AdminBoundary> boundaries) {
    for (AdminBoundary adm : boundaries) {
      if (!adm.countryCode().equals("null")) {
        countryMap.put(adm.countryCode(), adm.countryName());
        if (countryRegexMap.containsKey(adm.countryCode())) {
          String currentRegex = countryRegexMap.get(adm.countryCode());
          if (currentRegex.length() > adm.countryRegex().length()) {
            // the longest one wins if they are not all the same for each entry in the file
            countryRegexMap.put(adm.countryCode(), currentRegex);
          }//else do nothing
        } else {
          countryRegexMap.put(adm.countryCode(), adm.countryRegex());
        }

        if (!adm.getProvCode().equals("null")) {
          Map<String, String> provs = provMap.get(adm.countryCode());
          if (provs == null) {
            provs = new HashMap<>();
          }
          //if (!provs.containsKey(adm.getProvCode())) {
          String combined = adm.countryCode() + "." + adm.getProvCode();
          provs.put(combined, adm.provinceName());
          provMap.put(adm.countryCode(), provs);
          // }

          if (!adm.countyCode().equalsIgnoreCase("no_data_found") && !adm.countyName().equalsIgnoreCase("no_data_found")) {
            Map<String, String> counties = countyMap.get(combined);
            if (counties == null) {
              counties = new HashMap<>();
            }
            // if (!counties.containsKey(adm.getCountyCode())) {
            String countyid = combined + "." + adm.countyCode();
            counties.put(countyid, adm.countyName());
            countyMap.put(combined, counties);
            // }
          }
        }
      }
    }
    fillProvRegexMap();
    fillCountyRegexMap();
  }