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

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Add on for foreign language
    2003-12-31 00:41:31  anonymous2 [View]

    I meant "" is modified to "& a g r a v e ;" by html editors (and by this site too)

    Space = & n b s p ;
    = & a g r a v e ;
    = & a c i r c ;
    = & e a c u t e ;
    = & e u r o ;

    and so on...