# HG changeset patch # User Nicolas Saunier # Date 1356044645 18000 # Node ID 3af4c267a7bfe2f313fe342f793a7d265a9a6429 # Parent f21ef87f98f1c1eeaecaf618cd2bf7f47425557e generic simple LCSS diff -r f21ef87f98f1 -r 3af4c267a7bf python/utils.py --- a/python/utils.py Fri Dec 14 01:01:55 2012 -0500 +++ b/python/utils.py Thu Dec 20 18:04:05 2012 -0500 @@ -165,6 +165,21 @@ # maths section ######################### +def LCSS(l1, l2, threshold, distance): + "returns the longest common subsequence similarity + based on the threshold on distance between two elements of lists l1, l2" + from numpy import zeros + m = len(l1) + n = len(l2) + similarity = zeros((m+1,n+1)) + for i in xrange(1,m+1): + for j in xrange(1,n+1): + if distance(l1[i], l2[i])