In 1965 Vladmir Levenshtein created a distance algorithm. With Levenshtein distance, we measure similarity and match approximate strings with fuzzy logic.
Compute Levenshtein distance (or edit distance) between two strings is the number of deletions, insertions, or substitutions required to transform source string into target string.
For example, if source is "book" and target is "back", to transform "book" to "back" you will need to change first "o" to "a", second "o" to "c", without additional deletions and insertions, thus, Levenshtein distance will be 2. More about Levenshtein Algorithm you can read here.
This sample compare two text files similarity.
Play with it!