Serching of products correspondence

This is a discussion on Serching of products correspondence within the PHP Language forums, part of the PHP Programming Forums category; Hello. I have gotten the problem. I have two tables with products in mysql database. I need to code php ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-28-2007
tower.grv@gmail.com
 
Posts: n/a
Default Serching of products correspondence

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.

Reply With Quote
  #2 (permalink)  
Old 09-28-2007
Tyno Gendo
 
Posts: n/a
Default Re: Serching of products correspondence

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.
Reply With Quote
  #3 (permalink)  
Old 09-28-2007
C. (http://symcbean.blogspot.com/)
 
Posts: n/a
Default Re: Serching of products correspondence

On 28 Sep, 11:17, Tyno Gendo <nob...@example.com> 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.

Reply With Quote
  #4 (permalink)  
Old 09-28-2007
Jerry Stuckle
 
Posts: n/a
Default Re: Serching of products correspondence

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
==================
Reply With Quote
  #5 (permalink)  
Old 09-28-2007
petersprc
 
Posts: n/a
Default Re: Serching of products correspondence

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" <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.



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0