The first thing that came to my mind was Levenshtein Distance , but it is more focused on the similarity of words.
You can use tf-idf , but it will probably work better if your enclosure contains more than two documents.
An alternative could be the presentation of documents (messages) using a vector space model, for example:
(w_0, w_1, ..., w_k)
Where
k is the total number of terms (words) in your document.w_i is a member of i-th .
and then calculate the Hamming Distance , which basically compares two vectors (arrays) and counts the positions where they are different. You can first discard stop words (e.g. words such as prepositions, etc.).
Keep in mind that the user can change some words, use synonyms, etc. There are many models for the presentation of documents, the computational similarities between them. Some of them take into account the dependence of words in words, which gives more semantics to the process, while others do not.
source share