Page 1 of 1

Compare strings that doesn't match 100%

Posted: Thu Jan 25, 2007 6:12 am
by aka_eu
Hy to all,

I want to implement a small application for me, for odds comparison but unfortunately I got a dead end.

I succeeded to import the games and odds from all the bookmakers that is interesting me, but now I have some problem finding the same game on 5 bookmakers.

The problem is that they don't have all the same name for a team.

For example : Fc Koln (from Germany) can be find as : Koln or Coblenza.

And now I don;t know how to handle is the best manner the problem.

Can someone suggest me how to think this problem ? I was thinking on some AI or maybe to have some mysql tables for to write all the possibilities for a team (this will be do only the first time)

Posted: Thu Jan 25, 2007 6:58 am
by CoderGoblin
Regular expressions may be an answer or if you are searching a database look up full text searching for the relevent database.

Without being a bit more specific (e.g code example) it's hard to be any more precise.

Re: Compare strings that doesn't match 100%

Posted: Thu Jan 25, 2007 12:45 pm
by Christopher
aka_eu wrote:For example : Fc Koln (from Germany) can be find as : Koln or Coblenza.
You could use regular expressions and do something like:

Code: Select all

$bookmaker_name = 'Fc Koln';
$regex = '/(Koln|Coblenza)/';     // match 'Koln' or 'Coblenza'
if (preg_match($pattern, $bookmaker_name)) {
     // match found
} else {
     // no match
}

Posted: Thu Jan 25, 2007 12:54 pm
by John Cartwright

Code: Select all

$bookmaker_name = 'Fc Koln';
$regex = '/(Koln|Coblenza)/';     // match 'Koln' or 'Coblenza'
if (preg_match($pattern, $bookmaker_name)) {
     // match found
} else {
     // no match
}
Adding to arborints suggestion, you could do a preg_replace() to add AKA's to the groups aliases

Code: Select all

$bookmaker_name = 'Fc Koln';
preg_replace('/(Koln|Coblenza)/', '$1 (a.k.a. '. $bookmaker_name.')', $source);

Posted: Thu Jan 25, 2007 1:19 pm
by aka_eu
Yes of course that I understand that solution but the problem is that I don't have to know each time how the team will be wrote. For example maybe sometime a bookmaker instead of Fc Koln will write Fc Kon , so I was thing as something like AI algorithm that will understand himself when it will meat Fc Kon that is about Fc Koln

Posted: Thu Jan 25, 2007 1:30 pm
by feyd
FULL TEXT comparison in the database? similar_text() on the PHP side?

Posted: Thu Jan 25, 2007 1:30 pm
by Christopher
Well you could make the system "teachable" if you had it print out the name when it could not find a match. Then you could enter the new match to be added to the possible names for that team. So the system would "learn" (in a simple way).