private static Map getCountryCodes()

in geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/indexing/GeonamesProcessor.java [117:144]


  private static Map<String, String> getCountryCodes(File countryContextFile) {
    Map<String, String> ccs = new HashMap<>();
    try (BufferedReader reader = new BufferedReader(new FileReader(countryContextFile))){
      String line;
      boolean start = false;
      while ((line = reader.readLine()) != null) {
        if (!line.toLowerCase().startsWith("#iso\t") && !start) {
          continue;
        } else {
          start = true;
        }
        String[] values = line.split(TAB);

        String ccode = values[0].toLowerCase(); //this is the 2-digit ISO code
        String cname = values[4].toLowerCase();
        if (!ccode.isEmpty()) {
          ccs.put(ccode, cname);
        }

      }
    } catch (IOException ex) {
      ex.printStackTrace();
    }
    ccs.put("SS", "South Sudan");
    ccs.put("CS", "Kosovo");
    return ccs;

  }