Question: Write a Python function seq_sim(seq1, seq2, k) that takes as arguments two strings seq1 and seq2 and an integer k , and returns a floating
Write a Python function seq_sim(seq1, seq2, k) that takes as arguments two strings seq1 and seq2 and an integer k, and returns a floating point value between 0 and 1 (inclusive) giving the similarity between seq1 and seq2. The similarity value should be computed as the Jaccard index applied to the sets of k-grams of seq1 and seq2 (where k is the third argument to the function) ##### use jaccard index
Examples:
Call: seq_sim('aaaaab', 'aaaaaa', 3) Return value: 0.5
Call: seq_sim('aabaacaad', 'abaaba', 3) Return value: 0.42857142857142855
Call: seq_sim('aabaacaad', 'abaaba', 4) Return value: 0.2857142857142857
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
