![]() ![]() By comparing these shortened codes, it is possible to fuzzy match strings which are spelled differently but sound alike. The code contains the key information about how the string should sound if read aloud. These are algorithms which use sets of rules to represent a string using a short code. WHERE 'Cadinsky' % ANY(STRING_TO_ARRAY(name,' ')) The output gives two rows, including Vasily Kandinsky Phonetic algorithmsĪnother approach to fuzzy string matching comes from a group of algorithms called phonetic algorithms. The next query uses Postgres' STRING_TO_ARRAY function to split the artists' full names into arrays of separate names. The % operator lets you compare against elements of an array, so you can match against any part of the name. Perhaps you only have an idea of one part of the name. WHERE name % 'Andrey Deran' The output gives two artists, including one Andre Derain You can use the % operator in this case as shorthand for fuzzy matching names against a potential match: SELECT LIMIT 5 The closest match is Lee Krasner, followed by Lee Chesney ORDER BY SIMILARITY(name,'Lee Casner') DESC Perhaps you want to see the top five matches? SELECT WHERE SIMILARITY(name,'Claud Monay') > 0.4 The output is Claude Monet (with the correct spelling!) This allows for fuzzy matching, by setting a similarity threshold above which strings are considered to match.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |