Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-357

Dice Bigram Similarity Characters

Problem

The character bigram Dice coefficient is 2 |B(A) intersect B(B)| / (|B(A)| + |B(B)|) over bigram sets, with 1.0 when both strings are shorter than two characters.

Given the two strings, return the coefficient.

Hint

Build bigram sets first, then apply Dice.

Test cases

case 1
in: ["night","nacht"]
expected: 0.25
case 2
in: ["ab","ab"]
expected: 1
case 3
in: ["a","b"]
expected: 1
Starter codePython
def dice_bigram_similarity_characters(a, b):
    # Your code here
    pass

3 test cases · run your code against them in the editor