Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id BE228B5DE5D for ; Wed, 25 May 2011 12:43:07 -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 98661-01-7 for ; Wed, 25 May 2011 15:42:59 +0000 (UTC) X-Greylist: delayed 00:16:23.280248 by SQLgrey-1.7.6 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by mail.postgresql.org (Postfix) with ESMTP id 6FE3BB5DE21 for ; Wed, 25 May 2011 12:42:18 -0300 (ADT) Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1QPFy4-0006Lt-KN; Wed, 25 May 2011 09:25:52 -0600 Received: from [208.187.158.94] (helo=[172.16.1.234]) by in01.mta.xmission.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1QPFy4-0002ag-5V; Wed, 25 May 2011 09:25:52 -0600 Message-ID: <4DDD1F7C.5040008@gmail.com> Date: Wed, 25 May 2011 09:25:48 -0600 From: Rob Sargent User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: pgsql-sql@postgresql.org References: <20110522210526.0f8b66fa@dick.coachhouse> <20110522230041.28d1bc35@dick.coachhouse> <4DD9BB87.7070000@postnewspapers.com.au> <20110523163341.56edb1aa@dick.coachhouse> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-XM-SPF: eid=; ; ; mid=; ; ; hst=in01.mta.xmission.com; ; ; ip=208.187.158.94; ; ; frm=robjsargent@gmail.com; ; ; spf=neutral X-XM-AID: U2FsdGVkX19/LQRfKUnJpRr7VVq3+g8YQb7BOV7BT48= X-SA-Exim-Connect-IP: 208.187.158.94 X-SA-Exim-Mail-From: robjsargent@gmail.com X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;pgsql-sql@postgresql.org X-Spam-Relay-Country: Subject: Re: extracting location info from string X-SA-Exim-Version: 4.2.1 (built Fri, 06 Aug 2010 16:31:04 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.012 tagged_above=-5 required=5 tests=FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201105/155 X-Sequence-Number: 35439 On 05/24/2011 10:57 AM, Lew wrote: > Tarlika Elisabeth Schmitz wrote: >> Lew wrote: >>> 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. > >> I presume you are referring to my original post: >> CREATE TABLE person >> ( >> id integer NOT NULL, >> "name" character varying(256) NOT NULL, >> "location" character varying(256), >> CONSTRAINT person_pkey PRIMARY KEY (id) >> ); >> >> Sorry, this was just a TEMPORARY table I created for quick analysis of >> my CSV data (now renamed to temp_person). >> >> >> >> The target table is: >> CREATE TABLE person >> ( >> id integer NOT NULL, >> "name" character varying(100) NOT NULL, >> country character varying(3), >> county character varying(3), >> town character varying(50), >> CONSTRAINT trainer_pkey PRIMARY KEY (id), >> CONSTRAINT country_person_fk FOREIGN KEY (country) >> REFERENCES country (id) MATCH SIMPLE >> ON UPDATE CASCADE ON DELETE RESTRICT, >> CONSTRAINT county_person_fk FOREIGN KEY (country, county) >> REFERENCES county (country, code) MATCH SIMPLE >> ON UPDATE NO ACTION ON DELETE NO ACTION, >> ); > > Ah, yes, that makes much more sense. Temporary tables such as you > describe can be very convenient and effective. Thanks for the > clarification. > > I think this problem is very widespread, namely how to get structured > information out of freeform data. I've encountered it many times over > the years, as have so many I know. I believe that human intervention > will always be needed for this type of work, e.g., distinguishing place > names that seem the same or correlating ones that seem distinct. I also > don't know of any perfect approach. Perhaps the best one can find is a > probabilistic promise that error will be less than some epsilon. > > That said, if you have a robust process to correct errors as the user > population discovers them, then you can approach perfection > asymptotically. Sometimes the best solution to a technical problem is a > good human process. From an engineering standpoint, user feedback is a > vital element of homeostatic control. > > Edward W. Rouse's suggestion of a reference table to resolve different > forms of address or region identification would fit well with such a > process. > To minimize the ultimately quite necessary human adjudication, one might make good use of what is often termed "crowd sourcing": Keep all the distinct "hand entered" values and a map to the final human assessment. At least repeated oddities won't repeatedly involve hand editing.