Commit 4e137696 authored by Matija Obreza's avatar Matija Obreza
Browse files

Avoid using colloquial and historic names of countries

parent 3babf724
......@@ -30,6 +30,7 @@ import java.util.zip.ZipInputStream;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.StopWatch;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpEntity;
......@@ -50,6 +51,18 @@ import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
/*
The table 'alternate names' :
-----------------------------
0 alternateNameId : the id of this alternate name, int
1 geonameid : geonameId referring to id in table 'geoname', int
2 isolanguage : iso 639 language code 2- or 3-characters; 4-characters 'post' for postal codes and 'iata','icao' and faac for airport codes, fr_1793 for French Revolution names, abbr for abbreviation, link for a website, varchar(7)
3 alternate name : alternate name or name variant, varchar(200)
4 isPreferredName : '1', if this alternate name is an official/preferred name
5 isShortName : '1', if this is a short name like 'California' for 'State of California'
6 isColloquial : '1', if this alternate name is a colloquial or slang term
7 isHistoric : '1', if this alternate name is historic and was used in the past
*/
@Component
public class CountryAlternateNamesUpdater implements CountryNamesUpdater {
......@@ -227,14 +240,21 @@ public class CountryAlternateNamesUpdater implements CountryNamesUpdater {
ObjectNode jsonNames = objectMapper.createObjectNode();
for (String[] line : batchCopy) {
if (refnameId == 614540) {
System.err.println(ArrayUtils.toString(line));
}
boolean preferred = line.length > 4 && "1".equals(line[4]);
boolean colloquial = line.length > 6 && "1".equals(line[6]);
boolean historic = line.length > 7 && "1".equals(line[7]);
if (line[2] != null && line[2].length() == 2 && line[3] != null) {
boolean preferred = line.length >= 5 && "1".equals(line[4]);
if (preferred || jsonNames.get(line[2]) == null) {
jsonNames.put(line[2], line[3]);
if (!historic && !colloquial) {
if (preferred || jsonNames.get(line[2]) == null) {
jsonNames.put(line[2], line[3]);
}
}
}
if (line[2] != null && "link".equals(line[2])) {
boolean preferred = line.length >= 5 && "1".equals(line[4]);
if (preferred || wiki == null) {
wiki = line[3];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment