From d96b16650836046f79dc76641681445f97bd60ce Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 1 Feb 2015 08:11:28 +0100 Subject: [PATCH] countries: store abbreviations in include Static, so no reason to redo it every time. --- countries.plp | 13 ------------- tools/mkcountries-geonames | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/countries.plp b/countries.plp index 972e312..cd2040d 100644 --- a/countries.plp +++ b/countries.plp @@ -41,19 +41,6 @@ my $cc = do 'countries.inc.pl'; } else { $_ = $short || $name; - 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/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])((?%s', diff --git a/tools/mkcountries-geonames b/tools/mkcountries-geonames index 0eaf880..d9b938a 100755 --- a/tools/mkcountries-geonames +++ b/tools/mkcountries-geonames @@ -11,6 +11,23 @@ while (<>) { $cc{ lc $iso } = [ $name, $class ]; } +for (values %cc) { + for ($_->[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/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])((?