Text-Diff
Sat 17 May 2025
title: "Text Diff" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false
import difflib
str1 = "I understand how customers do their choice. Difference"
str2 = "I understand how customers do their choice."
seq = difflib.SequenceMatcher(None, str1, str2)
d = seq.ratio()*100
d
88.65979381443299
def get_similarity(str1, str2):
seq = difflib.SequenceMatcher(None, str1, str2)
d = seq.ratio()*100
return d
get_similarity(str1, str2)
88.65979381443299
get_similarity("Toronto is nice", "Toronto is looking nice")
78.94736842105263
Score: 10
Category: basics