I'm trying to find the strings in two list that almost match. Suppose there are two list as below
string_list_1 = ['apple_from_2018','samsung_from_2017','htc_from_2015','nokia_from_2010','moto_from_2019','lenovo_decommision_2017']
string_list_2 =
['apple_from_2020','samsung_from_2021','htc_from_2015','lenovo_decommision_2017']
Output
Similar = ['apple_from_2018','samsung_from_2017','htc_from_2015','lenovo_decommision_2017']
Not Similar =['nokia_from_2010','moto_from_2019']
I tried above one using below implementation but it is not giving proper result
similar = []
not_similar = []
for item1 in string_list_1:
for item2 in string_list_2:
if SequenceMatcher(a=item1,b=item2).ratio() > 0.90:
similar.append(item1)
else:
not_similar.append(item1)
When I tried above implementation it is not as expected. It would be appreciated if someone could identify the missing part and to get required result