I am trying to compare the similarities between 2 strings. I did it successfully by import
SequenceMatcher
The result should only return 3 possibilities,
i) Good which means second string contains in the first string. Eg: smack and mac
ii) Almost good which means part of second string contained in first string. Eg: smack and smart . Both are 60% similar and should be classified as almost good.
iii)Bad which means none of the elements in second string contained in first string. Eg:smack and van
However, If I would like to perform the same task without importhing SequenceMatcher, how will I be able to perform it? I am stuck at writing an algorithm to slice the strings and compare it with another. Also, is there anyways to define the algorithm SequenceMatcher?
Here's a link to my code
Sa=input('enter something A: ')
Sb=input('enter something B: ')
Sc=Sa.lower()
Sd=Sb.lower()
from difflib import SequenceMatcher
if Sd in Sc or SequenceMatcher(a=Sc,b=Sd).ratio() ==1:
print('Good')
if Sd not in Sc and 0<SequenceMatcher(a=Sc,b=Sd).ratio() <1:
print('Almost Good')
if SequenceMatcher(a=Sc,b=Sd).ratio() ==0:
print('Bad')
Much appreciated!