Serching of products correspondence
Serching of products correspondence
am 28.09.2007 12:07:42 von tower.grv
Hello.
I have gotten the problem.
I have two tables with products in mysql database. I need to code php
script that will connect products by name.
But names can be some different (like another words order, or
additional spaces, commas, dephises ect.)
Can someone recommend me php class of show some example how to do
this?
Thanks.
Re: Serching of products correspondence
am 28.09.2007 12:17:53 von Scott Wertz
tower.grv@gmail.com wrote:
> Hello.
>
> I have gotten the problem.
> I have two tables with products in mysql database. I need to code php
> script that will connect products by name.
> But names can be some different (like another words order, or
> additional spaces, commas, dephises ect.)
>
> Can someone recommend me php class of show some example how to do
> this?
>
> Thanks.
>
Could be tricky depending on how different the names are, but you can
use MySQL's LIKE function and perhaps it's REPLACE and REGEX options,
you might be best asking in a SQL newsgroup.
Try selecting into another table, then export the two tables into a
spreadsheet and manually compare afterwards for things that might be
missed or wrong.
Re: Serching of products correspondence
am 28.09.2007 13:19:52 von colin.mckinnon
On 28 Sep, 11:17, Tyno Gendo wrote:
> tower....@gmail.com wrote:
> > Hello.
>
> > I have gotten the problem.
> > I have two tables with products in mysql database. I need to code php
> > script that will connect products by name.
> > But names can be some different (like another words order, or
> > additional spaces, commas, dephises ect.)
>
> > Can someone recommend me php class of show some example how to do
> > this?
>
> > Thanks.
>
> Could be tricky depending on how different the names are, but you can
> use MySQL's LIKE function and perhaps it's REPLACE and REGEX options,
> you might be best asking in a SQL newsgroup.
>
> Try selecting into another table, then export the two tables into a
> spreadsheet and manually compare afterwards for things that might be
> missed or wrong.
Certainly it depends what the OP means by 'connect', if it's 'join'
then it should be at the database level - but that's a workaround of
the real problem where the same physical entity is described by
different labels in different contexts.
C.
Re: Serching of products correspondence
am 28.09.2007 13:47:56 von Jerry Stuckle
tower.grv@gmail.com wrote:
> Hello.
>
> I have gotten the problem.
> I have two tables with products in mysql database. I need to code php
> script that will connect products by name.
> But names can be some different (like another words order, or
> additional spaces, commas, dephises ect.)
>
> Can someone recommend me php class of show some example how to do
> this?
>
> Thanks.
>
You should be doing it in SQL, not PHP. Try comp.databases.mysql.
And it sounds like you need to normalize your database.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Serching of products correspondence
am 28.09.2007 14:01:24 von petersprc
Based on your description, I would assign a canonical name to each
product in the database and then match against that.
For items not matched in this step, you can try using the metaphone
algorithm on the canonical name. This can help detect some types of
spelling errors.
Any remaining items with no unique match could be handled manually.
function canonicalName($name)
{
$name = preg_replace('/[^0-9a-z\s]/i', '', $name);
$words = preg_split('/\s/s', $name, -1, PREG_SPLIT_NO_EMPTY);
sort($words);
return join(' ', $words);
}
$cName = canonicalName("Barbie Funhouse");
$metaphone = metaphone($cName);
echo "cName = $cName, metaphon = $metaphone\n";
$cName = canonicalName("Funhouse Barbie!");
$metaphone = metaphone($cName);
echo "cName = $cName, metaphon = $metaphone\n";
?>
The above outputs:
cName = Barbie Funhouse, metaphone = BRBFNHS
cName = Barbie Funhouse, metaphone = BRBFNHS
You can update each product with a cName and metaphone field.
On Sep 28, 5:07 am, "tower....@gmail.com" wrote:
> Hello.
>
> I have gotten the problem.
> I have two tables with products in mysql database. I need to code php
> script that will connect products by name.
> But names can be some different (like another words order, or
> additional spaces, commas, dephises ect.)
>
> Can someone recommend me php class of show some example how to do
> this?
>
> Thanks.