Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 469DEB5DBD8 for ; Sun, 22 May 2011 22:42:47 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 25295-03 for ; Mon, 23 May 2011 01:42:40 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [173.230.139.50]) by mail.postgresql.org (Postfix) with ESMTP id 485F5B5DBD2 for ; Sun, 22 May 2011 22:42:40 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by www.postnewspapers.com.au (Postfix) with ESMTP id B7E982D; Sun, 22 May 2011 21:42:40 -0400 (EDT) X-Virus-Scanned: amavisd-new at postnewspapers.com.au.com Received: from www.postnewspapers.com.au ([127.0.0.1]) by localhost (www.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id io2oBPvISA5e; Sun, 22 May 2011 21:42:40 -0400 (EDT) Received: from mail.postnewspapers.com.au (ppp171-128.static.internode.on.net [150.101.171.128]) by www.postnewspapers.com.au (Postfix) with ESMTP id 975DC27; Sun, 22 May 2011 21:42:39 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 88EB0AE6FA; Mon, 23 May 2011 09:42:38 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4K9PQ+y7-zRx; Mon, 23 May 2011 09:42:32 +0800 (WST) Received: from [10.1.1.3] (124-169-254-58.dyn.iinet.net.au [124.169.254.58]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 6D7ABAE8F2; Mon, 23 May 2011 09:42:32 +0800 (WST) Message-ID: <4DD9BB87.7070000@postnewspapers.com.au> Date: Mon, 23 May 2011 09:42:31 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: Andrej CC: Tarlika Elisabeth Schmitz , sql pgsql Subject: Re: extracting location info from string References: <20110522210526.0f8b66fa@dick.coachhouse> <20110522230041.28d1bc35@dick.coachhouse> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.185 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01, URIBL_BLACK=1.725 X-Spam-Level: X-Archive-Number: 201105/129 X-Sequence-Number: 35413 On 23/05/2011 9:11 AM, Andrej wrote: > On 23 May 2011 10:00, Tarlika Elisabeth Schmitz > wrote: >> On Sun, 22 May 2011 21:05:26 +0100 >> Tarlika Elisabeth Schmitz wrote: >> >>> A column contains location information, which may contain any of the >>> following: >>> >>> 1) null >>> 2) country name (e.g. "France") >>> 3) city name, region name (e.g. "Bonn, Nordrhein-Westfalen") >>> 4) city name, Rg. region name (e.g. "Frankfurt, Rg. Hessen") >>> 5) city name, Rg region name (e.g. "Frankfurt, Rg Hessen") >> >> >> I also need to cope with variations of COUNTRY.NAME and REGION.NAME. This is a hard problem. You're dealing with free-form data that might be easily understood by humans, but relies on various contextual information and knowledge that makes it really hard for computers to understand. If you want to do a good job of this, your best bet is to plug in 3rd party address analysis software that is dedicated to this task. Most (all?) such packages are commercial, proprietary affairs. They exist because it's really, really hard to do this right. > Another thing of great import is whether the city can occur in the > data column all by itself; if yes, it's next to impossible to distinguish > it from a country. Not least because some places are both, eg: Luxembourg The Vatican Singapore (The Grand Duchy of Luxembourg has other cities, but still serves as an example). -- Craig Ringer Tech-related writing at http://soapyfrogs.blogspot.com/