Iarsmans already gave you a link to the implementation of the algorithm in git, but if you want to read something about the theory, you can read to edit the distance and the distance of Levenshtein from wikipedia.
Simply put, for the editing distance algorithm, the goal is to calculate - a given set of basic editing operations by the type of data you are working on (lines in your case) - the minimum number of corrections so that one value (line) is identical to another.
source share