def to_similarity(distance, length):
    """Calculate a similarity measure from an edit distance.

    **Args**:

    * distance (int): The edit distance between two strings.
    * length (int): The length of the longer of the two strings the\
        edit distance is from.

    **Returns**:
    A similarity value from 0 to 1.0 (1 - (length / distance)), -1 if\
        distance is negative
    """
    return -1 if distance < 0 else 1.0 - distance / length