def score(x, y, w):
    """
    Calcutates directional distributional similarity http://dl.acm.org/citation.cfm?id=1897650
    >>> score([1, 2], [1, 3], {1:2, 2:1, 3:1})
    0.42857142857142855
    """
return sum(i for i in x if i in y) * w[i] / sum(i for i in x) * w[i]
Syntax of Mathemathical formula in Python