X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/b4ce208aa528529fbc34a035cf76b3f3e817e94a..ef4ff568419d6372f056f910b7e6e3d492ecec4d:/tools/mkcountries-geonames diff --git a/tools/mkcountries-geonames b/tools/mkcountries-geonames index 592ce75..32883ec 100755 --- a/tools/mkcountries-geonames +++ b/tools/mkcountries-geonames @@ -36,33 +36,51 @@ my %cc; # map of country code to info array wl => ["(Saint Lucia)", "c-na Xr", "(Saint Luc.)", 'lc'], wv => ["(Saint Vincent)", "c-na Xr", "(Saint Vin.)", 'vc'], yv => ["(Venezuela)", "c-sa Xr", undef, 've'], + + # WIPO, agreed not to use + ap => ["African Regional Industrial Property Organization", "Xi", "ARIPO"], # c-af + bx => ["Benelux Office for Intellectual Property", "Xi", "BOIP"], # c-eu + ef => ["European Community Patent Convention", "Xi", "CPC"], # c-eu + em => ["European Trademark Office", "Xi", "OHIM"], # c-eu + ep => ["European Patent Organization", "Xi", "EPOrg"], # c-eu + ev => ["Eurasian Patent Organization", "Xi", "EAPO"], # c-as + gc => ["Gulf Patent Office", "Xi", "GCCPO"], # c-as + ib => ["International Bureau of WIPO", "Xi", "IB WIPO"], + oa => ["African Intellectual Property Organization", "Xi", "OAPI"], # c-af + wo => ["World Intellectual Property Organization", "Xi", "WIPO"], ); while (<>) { /^#/ and next; # skip comments - my ($iso, $name, $cont) = (split /\t/)[0, 4, 8]; - my $class = "c-\L$cont"; - $cc{ lc $iso } = [ $name, $class ]; + my ($iso, $name, $cont, $tld) = (split /\t/)[0, 4, 8, 9]; + my @info = ($name, "c-\L$cont"); + $info[3] = $tld if $tld =~ s/\A\.// and $tld ne lc $iso; + $cc{ lc $iso } = \@info; } $cc{io}->[2] = "Chagos Islands"; $cc{um}->[2] = "U.S. isl."; for (values %cc) { - for ($_->[2] //= $_->[0]) { + my $abbr = do { + local $_ = $_->[2] // $_->[0]; s/,.*//; s/(?<=.)\(.*\)\s*//; s/ republic\b//gi; s/ islands?\b//gi; s/\bthe //g; s/ and / & /g and s/(?<=.)[a-z ]+//g; - s/\bsaint /st /gi; + s/ of / /g; + s/\bsa?int /st /gi; + s/United /Un. /gi; s/South(?:ern)? /S-/g; s/North(?:ern)? /N-/g; s/New /n./g; s/(\S)(\S+)-/$1-/g; # strip most chars preceding dash s/(\S{4}[b-df-hj-np-tv-xz])((?[2] = $abbr if $abbr ne $_->[0]; # short name if different } say "# automatically generated by $0";