Welcome to WebmasterWorld Guest from 54.163.84.199

Forum Moderators: coopster & jatar k

anyone know how wikipedia does string matches on all it's terms

   
10:06 am on Dec 1, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi,

i have to implement a string match involving persons names. we have a database of 5,000 names. these have to be detected in short paragraphs.

obviously i'd rather not loop through each line comparing 5000 entries ;)

does anyone have any experience with this or know how wikipedia do it?

many thanks
5:55 pm on Dec 1, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



well, i thought why not try it anyway... and it only takes microseconds to parse the 5000 names and preg_match:


foreach ($arr_names as $ID => $name)
{
if (preg_match('/(' . $name . ')\b/i', $_POST['str'], $matches))
{
$m[] = $matches[1];
}
}


(please don't try this with a wikipedia database of 10 million terms lol)
6:30 pm on Dec 1, 2011 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



If I had to guess I'm sure Wikipedia must limits the domain of words it selects from by subject matter (or some other meta data) for that particular article. Also, I'm sure they have some type of caching mechanism built in.

You should only need to do this find/replace when either the string changes or the names domain changes; in both cases, you only need to search what has changed (the new names or the new text) if you've already searched the text before. Timestamps on the "names" table should be able to aid in this.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month