Looking for library to estimate likeness of two strings

agenkin at gmail.com agenkin at gmail.com
Thu Feb 7 10:29:55 EST 2008


On Feb 7, 2:37 am, "Daniel Fetchinson" <fetchin... at googlemail.com>
wrote:
> Hi folks, just went through this thread and a related one from 2006
> and I was wondering what the best solution is for using these string
> metrics in a database search. If I want to query the database for a
> string or something that is close to it (close being defined by one of
> the string metrics discussed above) it seems I have to select each and
> every word from the database and compare it with the query word which
> is very ineffective.

I have never used sqlite database, but Postgres has a module that
implements levenshtein(), soundex() and metaphone() functions, so you
can do something like this:

SELECT * FROM s WHERE soundex(name) = soundex('john');
SELECT * FROM s WHERE difference(name, 'john') > 2;

http://www.postgresql.org/docs/8.3/static/fuzzystrmatch.html



More information about the Python-list mailing list