xxxxxxxxxx
-- Calculates the levenstein distance using the levenstein postgres extension
-- Also calculated similarity score
;WITH list AS (
SELECT 'hello' as word UNION ALL
SELECT 'hi' UNION ALL
SELECT 'help' UNION ALL
SELECT 'hallo' UNION ALL
SELECT 'halloo'
)
SELECT 'hallo' as word1, l.word as wordlist ,
levenshtein(l.word, 'hallo') as levenshtein_distance,
1.0 - levenshtein(l.word, 'hallo') / (1.0*length(l.word) + length('hallo')) as similarity_score
FROM list l