I have the following dataframe
Column1 Column2
tomato fruit tomatoes are not a fruit
potato la best potatoe are some sort of fruit
apple there are great benefits to appel
pear peer
and I would like to look up the word/sentence on the left with the sentences on the right and if there is a match on the max first two words (e.g. 'potato la' and leave out 'best') then it would give a score.
I have already used two different methods:
for i in range(0, len(Column1)):
store_it = SM(None, Column1[i], Column2[i]).get_matching_blocks()
print(store_it)
And
df['diff'] = df.apply(lambda x: diff.SequenceMatcher(None, x[0].strip(), x[1].strip()).ratio(), axis=1)
which I found on the internet.
The second one works fine, except that it tries to match the entire phrase. How can I match the words in the first column with the sentences in the second column so that it ultimately gives me a 'Yes' they are in the sentence (or partially) or 'No' they aren't.