Cosine similarity measures the distance between two vectors. This technique creates a vector that represents the number of elements found in a string.
The Apache Commons Text library's CosineSimilarity class supports this measurement. The class has a single default constructor and a single CosineSimilarity method. The method accepts two Map instances, representing the vectors. It returns a Double, representing their similarity.
More detailed explanations of cosine similarity can be found at https://en.wikipedia.org/wiki/Cosine_similarity and https://stackoverflow.com/questions/1746501/can-someone-give-an-example-of-cosine-similarity-in-a-very-simple-graphical-wa.