Skip to content

Instantly share code, notes, and snippets.

@karsany
karsany / dice_coeff.sql
Created July 19, 2011 23:30
Calculates Dice's Coefficient. Written in Oracle PL/SQL.
-------------------------------------------------------------------------------
-- Dice-Coefficient in Oracle PL/SQL
-- http://en.wikipedia.org/wiki/Dice%27s_coefficient
-- http://en.wikipedia.org/wiki/S%C3%B8rensen_similarity_index
-------------------------------------------------------------------------------
FUNCTION dice_coeff(p_str1 IN VARCHAR2, p_str2 IN VARCHAR2) RETURN NUMBER
DETERMINISTIC IS
co_substr_len CONSTANT NUMBER := 2;
TYPE ty_varchar_assoc IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(100);