def pairwise_analogy_func(wrap, a1, b1, a2, b2, weight_direct, weight_transpose):
    """
    Rate the quality of the analogy a1 : b1 :: a2 : b2.
    """
    va1 = wrap.get_vector(a1)
    vb1 = wrap.get_vector(b1)
    va2 = wrap.get_vector(a2)
    vb2 = wrap.get_vector(b2)

    value = (
        weight_direct * (vb2 - va2).dot(vb1 - va1)
        + weight_transpose * (vb2 - vb1).dot(va2 - va1)
        + vb2.dot(vb1)
        + va2.dot(va1)
    )
    return value