Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 8227FB5DBBF for ; Wed, 25 May 2011 19:07:43 -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 49291-01 for ; Wed, 25 May 2011 22:07:35 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by mail.postgresql.org (Postfix) with ESMTP id E578EB5DBDD for ; Wed, 25 May 2011 19:07:34 -0300 (ADT) Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1QPMEn-0000W8-NH; Wed, 25 May 2011 16:07:33 -0600 Received: from [208.187.158.94] (helo=[172.16.1.234]) by in02.mta.xmission.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1QPMEn-0005Z0-4y; Wed, 25 May 2011 16:07:33 -0600 Message-ID: <4DDD7DA2.7040309@gmail.com> Date: Wed, 25 May 2011 16:07:30 -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> <4DDD1F7C.5040008@gmail.com> <20110525221342.14e34046@dick.coachhouse> In-Reply-To: <20110525221342.14e34046@dick.coachhouse> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-XM-SPF: eid=; ; ; mid=; ; ; hst=in02.mta.xmission.com; ; ; ip=208.187.158.94; ; ; frm=robjsargent@gmail.com; ; ; spf=neutral X-XM-AID: U2FsdGVkX19rNqGGnkQk+KBcVgY189TW4ALxLlXc6aw= 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 in02.mta.xmission.com) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.888 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201105/159 X-Sequence-Number: 35443 On 05/25/2011 03:13 PM, Tarlika Elisabeth Schmitz wrote: > On Wed, 25 May 2011 09:25:48 -0600 > Rob Sargent wrote: > >> >> >> On 05/24/2011 10:57 AM, Lew wrote: >>> Tarlika Elisabeth Schmitz wrote: >>> >>>> CREATE TABLE person >>>> ( >>>> id integer NOT NULL, >>>> "name" character varying(256) NOT NULL, >>>> "location" character varying(256), >>>> CONSTRAINT person_pkey PRIMARY KEY (id) >>>> ); >>>> >>>> this was just a TEMPORARY table I created for quick analysis >>>> of my CSV data (now renamed to temp_person). > > CREATE TABLE country > ( > id character varying(3) NOT NULL, -- alpha-3 code > "name" character varying(50) NOT NULL, > CONSTRAINT country_pkey PRIMARY KEY (id) > ); > > >> 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. > > I was wondering how to do just that. I don't think it would be a good > idea to hard code this into the clean-up script. Take, for instance, > variations of COUNTRY.NAME spelling. Where would I store these? > > I could do with a concept for this problem, which applies to a lot of > string-type info. > I think you keep your current structures used for deducing the canonical forms, but with each unique input encounter you add it to you seen-thus-far list which becomes just one more check (possibly the first such check). create table address_input ( id unique/sequence, human_input character varying(256), resolution character varying(256) ) You may have to add a column for the type of input (if you know for instance the input is for street address v. country) or you may want the resolution to be portioned in to county, city and so on.