Re: How to achieve "accent-insensitive" searching

Richard Davis <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <[email protected]>
Steve Hay wrote:
> You'd heard of case-insensitive searching.  What about 
> "accent-insensitive" searching?


Hi Steve

No answers from here, I'm afraid, but it's an area that interests me, so
I'd love to hear how you do sort this out. Others must have solved this:
Google, for example, gives me similar (but not the same!?) results if I
search for "città" or "citta".

Since you're working with a web front end, I wonder if there's any
mileage in adapting the PHP approach below, that manipulates HTML
entities to zap accents. I know it doesn't get to the heart of your
problem on the database/SQL side, but it's intriguing nonetheless.

<quote>

In order to get rid of accents, we don't need to reach as far out as the
ascii tables. HTML has the lovely property that accents are added to the
character X in the form &Xmodif; where modif stands for the modification
of the original character: acute, grave, uml, etc.
There are far fewer accents than accented letters so this should do the
trick whether or not it is intended for HTML or not:

function replace_accents($in_string)
{
   $out_string = htmlentities($in_string);

   $out_string = str_replace("uml;", "", $out_string);
   $out_string = str_replace("acute;", "", $out_string);
   $out_string = str_replace("grave;", "", $out_string);
   $out_string = str_replace("cedil;", "", $out_string);
   $out_string = str_replace("ring;", "", $out_string);
   $out_string = str_replace("circ;", "", $out_string);
   $out_string = str_replace("tilde;", "", $out_string);
   $out_string = str_replace("lig;", "", $out_string);
   $out_string = str_replace("slash;", "", $out_string);

   $out_string = str_replace("&", "", $out_string);
   return $out_string;
}

The function above assumes there are only letter in the input (no
ampersand, < and >, quotes, etc).

[ from: http://php.selwerd.nl/manual/fr/function.str-replace.php ]

</quote>


Regards

Richard

P.S. I was also fascinated by this interesting article on related
problems of alphabetization: http://www.rostra.dk/alphabet/alpha_en.htm


-- 
/
\ Richard M Davis
/ Digital Archives Specialist
\ University of London Computer Centre
/ Tel: +44 (0) 20 7692 1350
\ mailto: [email protected]
/

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.