There is two string, str1 is pattern, str2 is a long text
str1 = 'how to do this weird task'
str2 = 'once upon a time...and smth long'
How to find out if str2 contains str1 or something similar to it - not necessarily equal to str1
Now i use Levenshtain.ratio
, a window with a length of str1 above str2.
res = [[str2[i:i+len(str1)],str1,ratio(str2[i:i+len(str1)],str1)] for i in range(len(str2)-len(str1))]
and choose maximum in res[:,2]
, but maybe smth better was created