def minmax(vec_x, vec_y):
    """Calculates the minmax similarity of two vectors.

    Calculates minmax similarity of two vectors vec_x and vec_y.
    Formula: minmax(X, Y) = sum(min(Xi, Yi))/sum(max(Xi, Yi))

    This baseline method will be used for further evaluation.
    """
    minsum = 0
    maxsum = 0

    for ngram in vec_x:
        if ngram in vec_y:
            # ngram is in both vectors
            minsum += min(vec_x[ngram], vec_y[ngram])
            maxsum += max(vec_x[ngram], vec_y[ngram])
        else:
            # ngram only in vec_x
            maxsum += vec_x[ngram]

    for ngram in vec_y:
        if ngram not in vec_x:
            # ngram only in vec_y
            maxsum += vec_y[ngram]

    if maxsum == 0:
        return 0

    return float(minsum) / maxsum