Your problem is this loop, which can append multiple copies of list_one
to lists
as you iterate over strings
:
for s in strings:
if SequenceMatcher(None, list_string, s).ratio() < 0.7:
strings.append(list_string)
lists.append(list_one)
e += 1
What you need to do is check if all SequenceMatcher
values are <0.7
and only append if they are. Something like this:
if all(SequenceMatcher(None, list_string, s).ratio() < 0.7 for s in strings):
strings.append(list_string)
lists.append(list_one)
e += 1
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…