Updated to take account of schema changes

git-svn-id: file:///svn/phpbb/trunk@1484 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-11-29 15:27:48 +00:00
parent 88872c4d22
commit 01d66751e9

View file

@ -10,8 +10,17 @@ function clean_words($entry, &$search, &$replace)
static $later_match = array("-", "~", "+", ".", "[", "]", "{", "}", ":", "\\", "/", "=", "#", "\"", ";", "*", "!"); static $later_match = array("-", "~", "+", ".", "[", "]", "{", "}", ":", "\\", "/", "=", "#", "\"", ";", "*", "!");
static $later_replace = 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 = " " . 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 // Replace line endings by a space
$entry = preg_replace("/[\n\r]/is", " ", $entry); $entry = preg_replace("/[\n\r]/is", " ", $entry);
// Remove URL's // Remove URL's
@ -62,9 +71,7 @@ function remove_common($percent, $delete_common = 0)
{ {
global $db; global $db;
$sql = " $sql = "SELECT COUNT(DISTINCT post_id) as total_posts
SELECT
COUNT(DISTINCT post_id) as total_posts
FROM " . SEARCH_MATCH_TABLE; FROM " . SEARCH_MATCH_TABLE;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if( !$result ) if( !$result )
@ -77,17 +84,10 @@ function remove_common($percent, $delete_common = 0)
$common_threshold = floor($total_posts * ( $percent / 100 )); $common_threshold = floor($total_posts * ( $percent / 100 ));
$sql = " $sql = "SELECT word_id
SELECT FROM " . SEARCH_MATCH_TABLE . "
word_id, GROUP BY word_id
count(word_id) AS word_occur HAVING count(word_id) > $common_threshold";
FROM
".SEARCH_MATCH_TABLE."
GROUP BY
word_id
HAVING
word_occur > $common_threshold
";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if( !$result ) if( !$result )
{ {
@ -177,9 +177,7 @@ for ($j = 0; $j < count($synonym_list); $j++)
// Fetch a batch of posts_text entries // Fetch a batch of posts_text entries
// //
$sql = " $sql = "
SELECT SELECT count(*) as total, max(post_id) as max_post_id
count(*) as total,
max(post_id) as max_post_id
FROM ". POSTS_TEXT_TABLE; FROM ". POSTS_TEXT_TABLE;
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
@ -201,10 +199,10 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
$batchcount++; $batchcount++;
$sql = "SELECT * $sql = "SELECT *
FROM " . FROM " . POSTS_TEXT_TABLE ."
POSTS_TEXT_TABLE ." WHERE post_id
WHERE BETWEEN $batchstart
post_id BETWEEN $batchstart AND $batchend"; AND $batchend";
if(!$posts_result = $db->sql_query($sql)) if(!$posts_result = $db->sql_query($sql))
{ {
$error = $db->sql_error(); $error = $db->sql_error();
@ -299,11 +297,11 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
while(list($junk, $row) = each($selected_words)) while(list($junk, $row) = each($selected_words))
{ {
$comma = ($sql_insert != '')? ', ': ''; $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." $sql = "INSERT INTO ".SEARCH_MATCH_TABLE."
(post_id, word_id, word_count, title_match) (post_id, word_id, title_match)
VALUES VALUES
$sql_insert $sql_insert
"; ";