good chemistry is complicated,
and a little bit messy -LW
Comparing inputs before inserting into MySQL for "sounds-like" similarityby hacker (Priest)
|on Apr 27, 2008 at 14:18 UTC||Need Help??|
hacker has asked for the
wisdom of the Perl Monks concerning the following question:
I have a series of databases with articles in them. These are front-ended by a Wordpress blog interface.
I've been importing the articles into Wordpress with a little spider I wrote that pulls them from a remote article resource. This part all works.
The relevant insert code looks something like this (wrapped for PM):
I had to alter some of the default tables in Wordpress to facilitate this by making post_title a VARCHAR(255) and setting it to unique as well as making user_login unique:
The inserts work, and so far no issues and no duplicate USERS in the database, but here's where it gets tricky...
When I'm inserting articles, sometimes there are articles which have "similar" titles and very similar content, written by two different people (plagiarism, no-doubt). Here are some examples:
There are probably more examples, but those are the two that I picked out visually.
I asked the MySQL folks, and they pointed me to Soundex, but it didn't look that easy to implement, and I've heard bad things about the pattern matching.
What I'm trying to figure out, is what is the best way to achieve this (preferably at article import time), so I can eliminate the potential for dupes?
An alternate solution is to import the "dupes", and mark them as "Unpublished", so I can manually review them later.
I don't want to add more tables to the db to facilitate this, I need to stay as close to "stock" as possible.
Ideas? Suggestions? Pseudocode?