nbdime
nbdime copied to clipboard
Implementing an edit distance function for any kind of diffable object
An edit distance function can be used to define approximate equality. The function needs to cover any type of diffable object, including nested dict and list structures.
For comparing strings, one alternative is the python-Levenshtein package:
https://github.com/ztane/python-Levenshtein/
This was used by the nbdiff.org project.
For strings or tuples containing lines of strings, difflib.SequenceMatcher(...).ratio()|quick_ratio() could be used, possibly using the autojunk heuristic to ignore blank lines.
For arbitrary nested structures we will anyway need a custom implementation.