compute distances between strings