calculate the cosine distance between 2 arrays of strings