All problems
Bigram Count Dictionary
Problem
Count consecutive token pairs and key them by the two tokens joined with a single space.
Given the token list, return a dictionary mapping each bigram string to its count.
Hint
Slide a window of two over the token list.
Test cases
case 1
in: [["a","b","a"]]
expected: {"a b":1,"b a":1}
case 2
in: [["x","x","x"]]
expected: {"x x":2}
case 3
in: [["only"]]
expected: {}
Starter codePython
def bigram_count_dictionary(tokens):
# Your code here
pass3 test cases · run your code against them in the editor