ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Building a Simple Search Engine with PHP
Subject:   Add on for foreign language
Date:   2003-12-31 00:35:06
From:   anonymous2
Hi All,


Thanks for this useful search engine.


The accents ("" in french for exemple) are encoded as "à" by html editors.


To get your search engine dealing with it, I put the following lines in populate.php :


/* Foreign site : convert french characters made by html editors : */


$patterns[0] = "/ /";
$patterns[1] = "/à/";
$patterns[2] = "/â/";
$patterns[3] = "/é/";
$patterns[4] = "/è/";
$patterns[5] = "/ê/";
$patterns[6] = "/î/";
$patterns[7] = "/ù/";
$patterns[8] = "/û/";
$patterns[9] = "/ç/";
$patterns[10] = "/œ/";
$patterns[11] = "/€/";
$patterns[12] = "/©/";


$replacements[0] = " ";
$replacements[1] = "";
$replacements[2] = "";
$replacements[3] = "";
$replacements[4] = "";
$replacements[5] = "";
$replacements[6] = "";
$replacements[7] = "";
$replacements[8] = "";
$replacements[9] = "";
$replacements[10] = "";
$replacements[11] = "";
$replacements[12] = "";


$buf = preg_replace($patterns, $replacements, $buf);


BETWEEN LINE


$buf = ereg_replace('/&\w;/', '', $buf);


AND LINE


/* Extract all words matching the regexp from the current line: */


It's not big deal but it works and it is easy to adapt to foreign languages.


Regards,


Louis
http://www.interactive-trails.com


1 to 1 of 1
1 to 1 of 1