Calculate distance matrix using EntropyNCD
masterYou can use the EntropyNCD distance metric from textdistance to compare contents of multiple files. EntropyNCD can be instantiated and then called with two strings to return the distance value. In the example below, it is used within a nested loop to build a list of distance tuples containing the names of the compared items and their calculated distance.
from textdistance import EntropyNCD
distances = []
for name1, content1 in licenses.items():
for name2, content2 in licenses.items():
# EntropyNCD(qval=None) initializes the metric
distances.append((name1, name2, EntropyNCD(qval=None)(content1, content2)))