countries: abbreviate West and East names
[sheet.git] / tools / mkcountries-geonames
index 88109dff3b740ec581491b3bfbc71f3cb942675a..56f85c41f0d921bfe1a5b88ae46cff534b35cf6c 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env perl
-use 5.012;
+use 5.014;
 use warnings;
 
 my %cc;  # map of country code to info array
@@ -19,7 +19,7 @@ my %cc;  # map of country code to info array
        dg => ["exceptionally reserved: Diego Garcia", "c-as Xr", "Diego Garcia", 'io'],
        ea => ["exceptionally reserved: Ceuta and Melilla", "c-af Xr", "Ceuta and Melilla"],
        eu => ["exceptionally reserved: European Union", "c-eu Xr", "European Union"],
-       ez => ["exceptionally reserved: European OTC derivatives", "c-eu Xr", "European OTC"],
+       ez => ["exceptionally reserved: European OTC derivatives", "c-eu Xr", "Eurozone"],
        fx => ["exceptionally reserved: Metropolitan France", "c-eu Xr", "Metropolitan France", 'fr'],
        ic => ["exceptionally reserved: Canary Islands", "c-af Xr", "Canary Islands"],
        su => ["exceptionally reserved: former USSR", "c-eu Xr", "USSR"],
@@ -60,6 +60,12 @@ my %cc;  # map of country code to info array
        ib => ["not used: International Bureau of WIPO", "Xi", "IB"],
        oa => ["not used: African Intellectual Property Organization", "Xi", "OAPI"], # c-af
        wo => ["not used: World Intellectual Property Organization", "Xi", "WIPO"],
+
+       # common user-assigned
+       xz => ["UN/LOCODE semantics: international waters", "Co Xi", "international"],
+       qo => ["Unicode semantics: Outlying Oceania", "c-oc Co Xi", "Oceania"],
+       qu => ["Unicode semantics: European Union deprecated reserve", "c-eu Co Xi", "EU", 'eu'],
+       zz => ["Unicode semantics: unknown or invalid territory", "Co Xi","unknown"],
 );
 
 while (<>) {
@@ -84,11 +90,13 @@ for (values %cc) {
                s/ and / & /g and s/(?<=.)[a-z ]+//g;
                s/ of / /g;
                s/\bsa?int /st /gi;
-               s/United /Un. /gi;
+               s/Un\Kited /. /gi;
                s/South(?:ern)? /S-/g;
                s/North(?:ern)? /N-/g;
+               s/West(?:ern)? /W-/g;
+               s/East(?:ern)? /E-/g;
                s/New /n./g;
-               s/(\S)(\S+)-/$1-/g;  # strip most chars preceding dash
+               s/(\w)(\w+)-/$1-/g;  # strip most chars preceding dash
                s/(\S{4}[b-df-hj-np-tv-xz])((?<!Austr)(?!land)\w{2,})/$1./g;  # abbreviate (at consonant)
                $_;
        };