Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D0CABB5DC21 for ; Mon, 23 May 2011 01:28:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 25654-01 for ; Mon, 23 May 2011 04:28:10 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id 757D4B5DBDD for ; Mon, 23 May 2011 01:28:10 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id p4N4SA3U060341 for ; Mon, 23 May 2011 01:28:10 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id p4N4P7xC015299 for pgsql-sql@postgresql.org; Mon, 23 May 2011 01:25:07 -0300 (ADT) (envelope-from news) From: Lew X-Newsgroups: pgsql.sql Subject: Re: extracting location info from string Date: Mon, 23 May 2011 00:25:16 -0400 Organization: albasani.net Lines: 63 Message-ID: References: <20110522210526.0f8b66fa@dick.coachhouse> <20110522230041.28d1bc35@dick.coachhouse> <4DD9BB87.7070000@postnewspapers.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: news.albasani.net; logging-data="3FRdZU7gISr/OEyNExJ8Tr5mFFwJGF8W6YsmV7N47TgB6kDa10L5xbSkUKCHbsZm7O8ck4zxN0SrFmAO3QrKEMc7UWHq65THSJmM0R5h9duj+E6Zn1/cnbVhUzgqS6tN"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 In-Reply-To: <4DD9BB87.7070000@postnewspapers.com.au> Cancel-Lock: sha1:Kt1eFW4lphmJeiE4pt44hQQx10k= To: pgsql-sql@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.225 tagged_above=-5 required=5 tests=BAYES_05=-0.5, T_FILL_THIS_FORM_SHORT=0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLACK=1.725 X-Spam-Level: * X-Archive-Number: 201105/131 X-Sequence-Number: 35415 On 05/22/2011 09:42 PM, Craig Ringer wrote: > 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. That isn't a table structure, that's a freeform text structure. You didn't state your question, Tarlika, but your database structure is terrible. For example, "region" and "country" should be different columns. Really! How you get your raw data into those columns can be interesting. > 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 These aren't really addresses, as the OP presents them. > 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). And,of course, you have to distinguish the City of London from London. New York City comprises five boroughs (counties), each of which is itself a city. (Brooklyn is one of the largest cities in the world all by itself.) "Region" has different meanings in different areas - it can mean part of a county, or state / province, or nation, or continent. "The Baltic region", "the Northeast", "upstate", "the North Country", "Europe" are all regions. The OP should share more about the semantics of their problem domain and whether they really intend those table structures to be table structures. Really? -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg