Now computing the similarity measure.