View Single Post
Old 04-20-2004, 08:06 AM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. The punctuation is on there for exact matches, but perhaps this exact match is too exact.

To relax the exact match and drop a lot, but not all, of the punctuation from the end of a word, do the following.

In phpdig_functions.php find:
Code:
$text = ereg_replace('[^'.$phpdig_words_chars[$enco
ding].' \\'._~@#$:&%/;,=-]+',' ',$text);
and afterwards add:
Code:
$text = ereg_replace('(['.$phpdig_words_chars[$enco
ding].'])[\\'._~@#$:&%/;,=-]+($|[[:space:]]$|[[:spa
ce:]]['.$phpdig_words_chars[$encoding].'])','\1\2',$text);
In search_function.php find:
Code:
if (eregi($what_query_chars,$query_to_parse)) {
	$query_to_parse = eregi_replace($what_que
ry_chars," ",$query_to_parse);
}
and afterwards add:
Code:
$query_to_parse = ereg_replace('(['.$phpdig_words_chars[PHPDIG_EN
CODING].'])[\\'.\_~@#$:&\%/;,=-]+($|[[:space:]]$|[[:space:]]['.$ph
pdig_words_chars[PHPDIG_ENCODING].'])','\1\2',$query_to_parse);
In search_function.php find:
Code:
if ($option == "exact") { // there are two instances of this
In both of these two if statements find:
Code:
$reg_strings = str_replace('@#@',' ',phpdigPregQuotes(str_repl
ace('\\\','',implode('@#@', $query_for_phrase_array))));
and replace with:
Code:
$reg_strings = str_replace('@#@','.* ',phpdigPregQuotes(str_repl
ace('\\\','',implode('@#@', $query_for_phrase_array))));
For breaking on a / or - character, see this thread. To exclude certain numbers, add a regex to the following line in robot_functions.php:
Code:
if (strlen($key) > SMALL_WORDS_SIZE and strlen($key) <= MAX_WOR
DS_SIZE and !isset($common_words[$key]) and ereg('^['.$phpdig_wo
rds_chars[PHPDIG_ENCODING].'#$]',$key))
For the changes to take effect, a new index would need to be done. Remember to remove any "word" wrapping from the above code.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote