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


Groups > comp.lang.php > #16690

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-28 01:48 +0200
Organization PointedEars Software (PES)
Message-ID <1522758.ErNA41kbOK@PointedEars.de> (permalink)
References (5 earlier) <2d87c8c4-e064-4d39-ae61-db1fef22406b@googlegroups.com> <ncrjss$fvo$1@dont-email.me> <4561092.OFe0Ho86XT@PointedEars.de> <ncujdj$pva$1@dont-email.me> <AKqdnUsbVeo9RWvLnZ2dnUU7-W3NnZ2d@posted.internetamerica>

Show all headers | View raw


Gordon Burditt wrote:

> "sunflow3r" is not *clearly* leetspeak; it may be a simple typo made
> by a hypothetical user of the OP's web site (*NOT* a typo by the
> OP in a post).

Yes, *that* is a distinct possibility that would explain the *apparent* 
disparity between the OP’s content and the OP’s explanations of it.
If that is the case, my apologies for assuming malice.
 
> What the OP might want is a "finger distance" algorithm of comparing
> two words (one correct, the other the way it was typed in).  Look
> at a typical keyboard and come up with a "distance" table between
> each key and each other key (or at least between the letter keys
> and each other key).  The distances will vary a bit depending on
> the assumed keyboard type.  Dvorak and USA keyboard layouts are
> really different.  As I understand it, USA and keyboards for various
> European countries have only a few keys moved around.

That depends very much on which European country you are talking about.
For example, considering *keys* is not enough, you must consider whole 
keyboard *layouts*, including *keymaps*.

In that regard, even the Standard German and Swiss German keyboard layouts 
are different from each other, even though both are based on QWERTZ.  And 
there is a Swiss French layout as well…

  [Having lived in Switzerland for almost a decade now, I even prefer the 
   Swiss German layout over the Standard German one that I grew up with.  
   (PHP) hacking is actually easier with it; for example, you have the “'”
   and “$” characters available without having to use the Shift key.]

> Do Chinese and USA keyboards even have more than a handful of keys in
> common? (Space, Enter, and Backspace?)

I do not know, but there are always Google and Wikipedia ;-)
 
<https://en.wikipedia.org/wiki/Keyboard_layout#Chinese>

> The "finger distance" between two equal-length words is the sum of
> the squares of the distances between corresponding letters.  (This
> gives a big penalty for really large distances on one character.)
> If the words are not equal length, you may need to come up with a
> "distance" for extra or missing characters.  A keyboard looks a bit
> like a grid of hexagons, with each letter key having adjacent
> characters left, right, up and to the left, up and to the right,
> down and to the left, and down and to the right.

Sounds like a really good idea.
 
> Unfortunately, this algorithm, unlike Soundex, needs to compare the
> word entered against each word in the database, which does not allow
> for a pre-prepared column to match against.  A pre-prepared column
> for each word in the database is impractical.

ACK.  But, in theory, one can have it defined as a stored function that is 
given two “words”, and two layout keys referring a mapping table, and that 
returns the “finger distance”.

-- 
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