diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2001-11-29 15:27:48 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2001-11-29 15:27:48 +0000 |
commit | 01d66751e9fcfca84c2f3fd420a768dcba4b0f9d (patch) | |
tree | 9ea8023b972626bb45e5a42e1b486c84bc9a332f /phpBB/develop | |
parent | 88872c4d22174ebe772d271ed594b5da5f98a9a1 (diff) | |
download | forums-01d66751e9fcfca84c2f3fd420a768dcba4b0f9d.tar forums-01d66751e9fcfca84c2f3fd420a768dcba4b0f9d.tar.gz forums-01d66751e9fcfca84c2f3fd420a768dcba4b0f9d.tar.bz2 forums-01d66751e9fcfca84c2f3fd420a768dcba4b0f9d.tar.xz forums-01d66751e9fcfca84c2f3fd420a768dcba4b0f9d.zip |
Updated to take account of schema changes
git-svn-id: file:///svn/phpbb/trunk@1484 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/develop')
-rw-r--r-- | phpBB/develop/search_fill.php | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/phpBB/develop/search_fill.php b/phpBB/develop/search_fill.php index 42c97e64aa..2c34a3a314 100644 --- a/phpBB/develop/search_fill.php +++ b/phpBB/develop/search_fill.php @@ -10,8 +10,17 @@ function clean_words($entry, &$search, &$replace) static $later_match = array("-", "~", "+", ".", "[", "]", "{", "}", ":", "\\", "/", "=", "#", "\"", ";", "*", "!"); static $later_replace = array(" ", " ", " ", " ", " ", " ", " ", " ", " ", " " , " ", " ", " ", " ", " ", " ", " "); + static $sgml_match = array(" ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ"); + static $sgml_replace = array(" ", "s", "a", "a", "a", "a", "a", "a", "a", "c", "e", "e", "e", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "t", "y"); + + static $accent_match = array("ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ"); + static $accent_replace = array("s", "a", "a", "a", "a", "a", "a", "a", "c", "e", "e", "e", "e", "i", "i", "i", "i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "t", "y"); + $entry = " " . strip_tags(strtolower($entry)) . " "; + $entry = str_replace($sgml_match, $sgml_match, $entry); + $entry = str_replace($accent_match, $accent_replace, $entry); + // Replace line endings by a space $entry = preg_replace("/[\n\r]/is", " ", $entry); // Remove URL's @@ -62,9 +71,7 @@ function remove_common($percent, $delete_common = 0) { global $db; - $sql = " - SELECT - COUNT(DISTINCT post_id) as total_posts + $sql = "SELECT COUNT(DISTINCT post_id) as total_posts FROM " . SEARCH_MATCH_TABLE; $result = $db->sql_query($sql); if( !$result ) @@ -75,19 +82,12 @@ function remove_common($percent, $delete_common = 0) $total_posts = $db->sql_fetchrow($result); $total_posts = $total_posts['total_posts']; - $common_threshold = floor($total_posts * ($percent/100)); - - $sql = " - SELECT - word_id, - count(word_id) AS word_occur - FROM - ".SEARCH_MATCH_TABLE." - GROUP BY - word_id - HAVING - word_occur > $common_threshold - "; + $common_threshold = floor($total_posts * ( $percent / 100 )); + + $sql = "SELECT word_id + FROM " . SEARCH_MATCH_TABLE . " + GROUP BY word_id + HAVING count(word_id) > $common_threshold"; $result = $db->sql_query($sql); if( !$result ) { @@ -177,9 +177,7 @@ for ($j = 0; $j < count($synonym_list); $j++) // Fetch a batch of posts_text entries // $sql = " - SELECT - count(*) as total, - max(post_id) as max_post_id + SELECT count(*) as total, max(post_id) as max_post_id FROM ". POSTS_TEXT_TABLE; if(!$result = $db->sql_query($sql)) { @@ -201,10 +199,10 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize) $batchcount++; $sql = "SELECT * - FROM " . - POSTS_TEXT_TABLE ." - WHERE - post_id BETWEEN $batchstart AND $batchend"; + FROM " . POSTS_TEXT_TABLE ." + WHERE post_id + BETWEEN $batchstart + AND $batchend"; if(!$posts_result = $db->sql_query($sql)) { $error = $db->sql_error(); @@ -299,11 +297,11 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize) while(list($junk, $row) = each($selected_words)) { $comma = ($sql_insert != '')? ', ': ''; - $sql_insert .= "$comma($post_id, ".$row['word_id'].", ".$word_count[$row['word_text']]." ,0)"; + $sql_insert .= "$comma($post_id, ".$row['word_id'].", 0)"; } $sql = "INSERT INTO ".SEARCH_MATCH_TABLE." - (post_id, word_id, word_count, title_match) + (post_id, word_id, title_match) VALUES $sql_insert "; |