Welcome! Log In Create A New Profile

Advanced

Language depending common.txt files

Posted by Tec 
Tec
Language depending common.txt files
July 25, 2007 05:48PM
For all those who are using Sphider in a multi-language environment or have to index different languages, it might be helpful to use language depending common.txt files. I think this is much more comfortable than to maintain one big one.
Here is an example for 2 languages like English and XYZ (as you need).

Prepare a file including all your English common words. Name this file common_eng.txt and store it in folder .../include/

Prepare another file including all your second language common words. Name this file common_xyz.txt and store it also in folder .../include/


Open .../include/commonfuncs.php and search for:

$common = array
(
);

$lines = @file($include_dir.'/common.txt');

if (is_array($lines)) {
while (list($id, $word) = each($lines))
$common[trim($word)] = 1;
}

Delete all that and replace it with the following:


$common_eng = array
(
);

$lines = @file($include_dir.'/common_eng.txt'); // read first file
if (is_array($lines)) {
while (list($id, $word) = each($lines)) // build first array
$common_eng[trim($word)] = 1;
}

$common_de = array
(
);

$lines = @file($include_dir.'/common_xyz.txt'); // read second file
if (is_array($lines)) {
while (list($id, $word) = each($lines)) // build second array
$common_xyz[trim($word)] = 1;
}



$common = array_merge($common_eng,$common_xyz); // merge both so we remain compatible with standard Sphider


Sphiders common.txt will not be used anymore. Now your new files are relevant for index, re-index and search-query (ignored words).

Happy coding

Tec
Sorry, only registered users may post in this forum.

Click here to login