in geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/indexing/USGSProcessor.java [226:249]
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.getProvinceName();
String country = adm.getCountryName();
/*
* this is the standard format of the country context file... Geonames
* data will have an empty string for the county
*/
String line = adm.getCountryCode() + "\t" + adm.getProvCode() + "\t" + adm.getCountyCode() + "\t" + country + "\t" + province + "\t" + adm.getCountyName() + "\t"
+ "(U\\.S\\.[ $]|U\\.S\\.A\\.[ $]|United States|the US[ $]|a us[ $])" + "\t" + adm.getProvinceName() + "\t" + adm.getCountyName() + "\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");
}