Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #16684

Re: Fuzzy searching inside a MySQL DB

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.php
Subject Re: Fuzzy searching inside a MySQL DB
Date 2016-03-25 19:26 +0100
Organization PointedEars Software (PES)
Message-ID <37433016.JoR0espfI3@PointedEars.de> (permalink)
References (6 earlier) <ncrjss$fvo$1@dont-email.me> <4561092.OFe0Ho86XT@PointedEars.de> <ncujdj$pva$1@dont-email.me> <368a5874-e081-4843-88a2-49c63b03e404@googlegroups.com> <nd3mmo$7j4$1@dont-email.me>

Show all headers | View raw


Mike Mellen wrote:

> On 3/25/2016 3:03 AM, bit-naughty@hotmail.com wrote:
>> On Thursday, March 24, 2016 at 8:35:32 AM UTC+5:30, Mike Mellen wrote:
>>> If this description is correct (OP - could you please verify?)
>> Yes, it has nothing to do with "leetspeak" - its more like, do you know
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> that rap group NWA - that stands for "Niggaz With Attitude" - so what if
>> someone searches for .... "Niggers with Attitude".....? They have a song
>> called "Fuck Tha Police", so... what if someone searches for "Fuck The
>> Police"....? THAT kind of thing......

Your example (OP) *definitely* had leetspeak in it, so by now you have 
mislead us *and* lied to us.  I am not surprised of that.
 
> You can test it for yourself.  From the mySQL command line, just enter
> 
> select soundex("expr1");
> select soundex("expr2");
> 
> where expr1 and expr2 are the two strings you want to compare; note they
> should be inside quotes. You can see the soundex codes that are
> generated.  If you don't consistently get matching codes for typical
> search strings your users might enter, you could then use the PHP
> levenshtein() or similar_text() functions on the soundex codes to
> determine how "close" the matches are, and use that result to determine
> if you have a match. It won't be perfect, but only you can decide what
> is "close enough".

You are not paying attention.

As I showed, the Soundex strings of “expr1” and “expr2” are identical 
because *Soundex* *ignores* *non-letters*:

--------------------------------------------------------------------------
$ mysql -u root -p <<<'SELECT SOUNDEX("good4you"), SOUNDEX("2good2Btrue"), 
SOUNDEX("goodBtrue"), SOUNDEX("togoodtobetrue")\G'
Enter password: 
*************************** 1. row ***************************
      SOUNDEX("good4you"): G300
   SOUNDEX("2good2Btrue"): G3136
     SOUNDEX("goodBtrue"): G3136
SOUNDEX("togoodtobetrue"): T23136
-------------------------------------------------------------------------

Notice that the first, second, and third Soundex value begin with “G”, and 
the fourth one with “T”.  Notice that the second and third value are 
*identical*.  Notice that the second, third, and fourth value end in “3136”; 
this comes from

      G    3      00
      g oo d 4you

      G    3     1   3 6
    2 g oo d 2   B   t r ue

      G    3     1   3 6
      g oo d     B   t r ue

  T   2    3     1   3 6
  t o g oo d t o b e t r ue

<https://en.wikipedia.org/wiki/Soundex#American_Soundex>

levensthein() and similar_text() *work* *differently*.

-- 
PointedEars
Zend Certified PHP Engineer 
<http://www.zend.com/en/yellow-pages/ZEND024953> | Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Fuzzy searching inside a MySQL DB bit-naughty@hotmail.com - 2016-03-17 10:16 -0700
  Re: Fuzzy searching inside a MySQL DB Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-17 13:34 -0400
  Re: Fuzzy searching inside a MySQL DB "R.Wieser" <address@not.available> - 2016-03-17 18:37 +0100
  Re: Fuzzy searching inside a MySQL DB Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-03-17 14:53 -0400
    Re: Fuzzy searching inside a MySQL DB Dr Eberhard Lisse <nospam@lisse.NA> - 2016-03-22 16:35 +0200
  Re: Fuzzy searching inside a MySQL DB Mike Mellen <mmellen@intellikey.com> - 2016-03-17 16:27 -0400
    Re: Fuzzy searching inside a MySQL DB bit-naughty@hotmail.com - 2016-03-21 11:09 -0700
      Re: Fuzzy searching inside a MySQL DB Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-03-21 14:22 -0400
      Re: Fuzzy searching inside a MySQL DB "R.Wieser" <address@not.available> - 2016-03-21 19:24 +0100
      Re: Fuzzy searching inside a MySQL DB Mike Mellen <mmellen@intellikey.com> - 2016-03-21 14:30 -0400
        Re: Fuzzy searching inside a MySQL DB Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-21 23:04 +0100
          Re: Fuzzy searching inside a MySQL DB bit-naughty@hotmail.com - 2016-03-22 00:31 -0700
            Re: Fuzzy searching inside a MySQL DB Mike Mellen <mmellen@intellikey.com> - 2016-03-22 10:15 -0400
              Re: Fuzzy searching inside a MySQL DB Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-22 21:53 +0100
                Re: Fuzzy searching inside a MySQL DB Mike Mellen <mmellen@intellikey.com> - 2016-03-23 13:26 -0400
                Re: Fuzzy searching inside a MySQL DB bit-naughty@hotmail.com - 2016-03-25 00:03 -0700
                Re: Fuzzy searching inside a MySQL DB Mike Mellen <mmellen@intellikey.com> - 2016-03-25 11:52 -0400
                Re: Fuzzy searching inside a MySQL DB Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-25 19:26 +0100
                Re: Fuzzy searching inside a MySQL DB Mike Mellen <mmellen@intellikey.com> - 2016-03-25 15:51 -0400
                Re: Fuzzy searching inside a MySQL DB Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-25 21:52 +0100
                Re: Fuzzy searching inside a MySQL DB Jerry Stuckle <jstucklex@attglobal.net> - 2016-03-25 20:20 -0400
                Re: Fuzzy searching inside a MySQL DB Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-03-25 12:11 -0400
                Re: Fuzzy searching inside a MySQL DB Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-25 08:49 +0100
                Re: Fuzzy searching inside a MySQL DB gordonb.3vp6x@burditt.org (Gordon Burditt) - 2016-03-26 13:44 -0500
                Re: Fuzzy searching inside a MySQL DB bit-naughty@hotmail.com - 2016-03-27 12:42 -0700
                Re: Fuzzy searching inside a MySQL DB Mike Mellen <mmellen@intellikey.com> - 2016-03-28 15:02 -0400
                Re: Fuzzy searching inside a MySQL DB Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-28 01:48 +0200
            Re: Fuzzy searching inside a MySQL DB Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-22 21:50 +0100

csiph-web