public static void writeCountryContextFile()

in geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/indexing/USGSProcessor.java [231:256]


  public static void writeCountryContextFile(File outfile, Map<String, AdminBoundary> adms) {

    try (BufferedWriter bw = new BufferedWriter(new FileWriter(outfile, true))) {
      for (String admkey : adms.keySet()) {
        AdminBoundary adm = adms.get(admkey);
        if (adm == null) {
          continue;
        }
        String province = adm.provinceName();
        String country = adm.countryName();
        /*
         * this is the standard format of the country context file... Geonames
         * data will have an empty string for the county
         */
        String line = adm.countryCode() + TAB + adm.getProvCode() + TAB + adm.countyCode() +
                TAB + country + TAB + province + TAB + adm.countyName() + TAB
                + "(U\\.S\\.[ $]|U\\.S\\.A\\.[ $]|United States|the US[ $]|a us[ $])" +
                TAB + adm.provinceName() + TAB + adm.countyName() + "\n";
        bw.write(line);
        //  System.out.println(line);
      }
    } catch (IOException ex) {
      Logger.getLogger(GeonamesProcessor.class.getName()).log(Level.SEVERE, null, ex);
    }
    System.out.println("successfully wrote USGS entries to country context file");
  }