All problems
Weighted Jaccard Token Similarity
Problem
The weighted Jaccard (Ruzicka) similarity of two token multisets is sum_t min(count_a, count_b) / sum_t max(count_a, count_b); define it as 1.0 when both multisets are empty.
Given two token lists, return the similarity.
Hint
Weight by counts and compare min against max per token.
Test cases
case 1
in: [["a","a","b"],["a","b","b"]]
expected: 0.5
case 2
in: [["x"],["y"]]
expected: 0
case 3
in: [[],[]]
expected: 1
Starter codePython
def weighted_jaccard_token_similarity(tokens_a, tokens_b):
# Your code here
pass3 test cases · run your code against them in the editor