Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 06:02 PM
Andreas
 
Posts: n/a
Default How to find double entries

Hi,

how can I find double entries in varchar columns where the content is
not 100% identical because of a spelling error or the person considered
it "looked nicer" that way?

I'd like to identify and then merge records of e.g. 'google', 'gogle',
'guugle'

Then I want to match abbrevations like 'A-Company Ltd.', 'a company
ltd.', 'A-Company Limited'

Is there a way to do this?
It would be OK just to list candidats up to be manually checked afterwards.


Regards
Andreas

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 06:02 PM
Craig Ringer
 
Posts: n/a
Default Re: How to find double entries

Andreas wrote:
> Hi,
>
> how can I find double entries in varchar columns where the content is
> not 100% identical because of a spelling error or the person considered
> it "looked nicer" that way?


When doing some near-duplicate elimination as part of converting a
legacy data set to PostgreSQL I found the `fuzzystrmatch' contrib module
immensely helpful.

http://www.postgresql.org/docs/curre...ystrmatch.html

--
Craig Ringer

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 06:02 PM
Tom Lane
 
Posts: n/a
Default Re: How to find double entries

Andreas <maps.on@gmx.net> writes:
> I'd like to identify and then merge records of e.g. 'google', 'gogle',
> 'guugle'


> Then I want to match abbrevations like 'A-Company Ltd.', 'a company
> ltd.', 'A-Company Limited'


> Is there a way to do this?
> It would be OK just to list candidats up to be manually checked afterwards.


There are some functions in contrib/fuzzystrmatch that seem like they'd
help you find candidate duplicates. contrib/pg_trgm and text search
might also offer promising tools.

What's really a duplicate sounds like a judgment call here, so you
probably shouldn't even think of automating it completely.

regards, tom lane

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-19-2008, 06:02 PM
Tena Sakai
 
Posts: n/a
Default Re: How to find double entries

Hi,

In a recent linux magazine article (http://www.linux-mag.com/id/5679)
there was a mentioning of Full-Text Search Integration. Which I know
nothing about, but sounded interesting to me. You might want to
check it out.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu


-----Original Message-----
From: pgsql-sql-owner@postgresql.org on behalf of Andreas
Sent: Tue 4/15/2008 8:15 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] How to find double entries

Hi,

how can I find double entries in varchar columns where the content is
not 100% identical because of a spelling error or the person considered
it "looked nicer" that way?

I'd like to identify and then merge records of e.g. 'google', 'gogle',
'guugle'

Then I want to match abbrevations like 'A-Company Ltd.', 'a company
ltd.', 'A-Company Limited'

Is there a way to do this?
It would be OK just to list candidats up to be manually checked afterwards.


Regards
Andreas

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-19-2008, 06:02 PM
Volkan YAZICI
 
Posts: n/a
Default Re: How to find double entries

On Wed, 16 Apr 2008, Andreas <maps.on@gmx.net> writes:
> how can I find double entries in varchar columns where the content is
> not 100% identical because of a spelling error or the person
> considered it "looked nicer" that way?
>
> I'd like to identify and then merge records of e.g. 'google',
> gogle', 'guugle'
>
> Then I want to match abbrevations like 'A-Company Ltd.', 'a company
> ltd.', 'A-Company Limited'
>
> Is there a way to do this?
> It would be OK just to list candidats up to be manually checked
> afterwards.


You can try something similar to below example. (levenshtein(text, text)
function is supplied by fuzzystrmatch module.)

SELECT T1.col, T2.col
FROM tbl AS T1,
INNER JOIN tbl AS T2
ON T1.col <> T2.col AND
levenshtein(T1.col, T2.col) < (length(T1.col) * 0.5)


Regards.

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-19-2008, 06:02 PM
Vivek Khera
 
Posts: n/a
Default Re: How to find double entries


On Apr 15, 2008, at 11:23 PM, Tom Lane wrote:
> What's really a duplicate sounds like a judgment call here, so you
> probably shouldn't even think of automating it completely.


I did a consulting gig about 10 years ago for a company that made
software to normalize street addresses and names. Literally dozens of
people worked there, and that was their primary software product. It
is definitely not a trivial task, as the rules can be extremely complex.


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-19-2008, 06:02 PM
Craig Ringer
 
Posts: n/a
Default Re: How to find double entries

Vivek Khera wrote:
>
> On Apr 15, 2008, at 11:23 PM, Tom Lane wrote:
>> What's really a duplicate sounds like a judgment call here, so you
>> probably shouldn't even think of automating it completely.

>
> I did a consulting gig about 10 years ago for a company that made
> software to normalize street addresses and names. Literally dozens of
> people worked there, and that was their primary software product. It is
> definitely not a trivial task, as the rules can be extremely complex.


From what little I've personally seen of others' addressing handling,
some (many/most?) people who blindly advocate full normalisation of
addresses either:

(a) only care about a rather restricted set of address types ("ordinary
residential addresses in <my country>", though that can be bad enough);
or
(b) don't know how horrible addressing is .... yet ... and are going to
find out soon when their highly normalized addressing schema proves
incapable of representing some address they've just been presented with.

with most probably falling into the second category.

Overly strict addressing, without the associated fairly extreme
development effort to get it even vaguely right, seems to lead to users
working around the broken addressing schema by entering bogus data.


Personally I'm content to provide lots of space for user-formatted
addresses, only breaking out separate fields for the post code
(Australian only), the city/suburb, the state, and the country - all
stored as strings. The only DB level validation is a rule preventing the
entry of invalid & undefined postcodes for Australian addresses, and
preventing the entry of invalid Australian states. The app is used
almost entirely with Australian addresses, and there's a definitive, up
to date list of australian post codes available from the postal
services, so it's worth a little more checking to protect against basic
typos and misunderstandings.

The app provides some more help at the UI level for users, such as
automatically filling in the state and suburb if an Australian post code
is entered. It'll warn you if you enter an unknown Australian
suburb/city for an entry in Australia. For everything else I leave it to
the user and to possible later validation and reporting.

I've had good results with this policy when working with other apps that
need to handle addressing information, and I've had some truly horrible
experiences with apps that try to be too strict in their address checking.

--
Craig Ringer

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-20-2008, 06:13 AM
Jean-David Beyer
 
Posts: n/a
Default Re: How to find double entries

Andreas wrote:
> Hi,
>
> how can I find double entries in varchar columns where the content is not
> 100% identical because of a spelling error or the person considered it
> "looked nicer" that way?
>
> I'd like to identify and then merge records of e.g. 'google', 'gogle',
> 'guugle' Then I want to match abbrevations like 'A-Company Ltd.', 'a
> company ltd.', 'A-Company Limited'
>
> Is there a way to do this? It would be OK just to list candidats up to be
> manually checked afterwards.
>
>

This is really tough, whether you use postgreSQL or not. I once worked for a
large regulated monopoly who had to look up stuff in telephone books a lot.
Several of us got a magnetic tape with all the business, professional, and
government listings for a county on Long Island in it; we thought
residential would be too easy and did not have the disk space for it (in
those days, hard drives cost $40,000 and held 40 Megabytes).

One of the things we did was do leading substring partial matching. I.e., we
could look for "J Smith" and find "Smith, John Robert"; we could find him
with "Rob Smit" as well.

This helped because people did not put their names in the right order.
Sometimes they said "Smith, John" and other times they said "John Smith" or
"J Smith" and meant the same guy. Sometimes they said "White St" or "White
Street" when they meant "White Road". And so it went. Sometimes they spelled
her name "Jeannine" when she spelled it "Genine". So the question always
ended up being what did they really mean.

To make matters worse, someone had run a program over the data to spell out
abbreviations, but that generated "42 Saint" instead of "42 Street" and
problems like that. Also, if a field was too big, the data-entry clerks just
kept on typing into the next field, so a lot of entries had, as an address,
"If no entry call"

I stuck in a phonetic matcher (similar to Soundex coding) so that a query
for "Ristorante Italiano" would find "Mom's Pizza Italian Restaurant". It
would also find Genine whey you were looking for Jeannine.

People often got the towns wrong. Around here, there is a town on the map,
but the telephone company had that in another town, and the tax collector
had it in yet another town. So towns were weighted lower than names.

For government listings, there was a separate record for each line in the
telephone book, so you would get entries like this, each line a separate record:

U S Government
Federal Aviations Administration
Kennedy Airport
Pilot Information
Arrivals
Departures

We had to make it find "Pilot Arrivals" so indexing was not trivial until
you figured out how to do it.

But when all was said and done, we put a program on the output that
displayed answers in terms of decreasing goodness of match and stuck the
users with deciding what they wanted. A big trick was to do all this without
doing a sequential search of the database.


--
.~. Jean-David Beyer Registered Linux User 85642.
/V\ PGP-Key: 9A2FC99A Registered Machine 241939.
/( )\ Shrewsbury, New Jersey http://counter.li.org
^^-^^ 21:30:01 up 33 days, 2:32, 1 user, load average: 4.06, 4.07, 4.11

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:24 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758