I have a dictionary of words with their frequencies as follows.
mydictionary = {\'yummy tim tam\':3, \'milk\':2, \'chocolates\':5, \'biscuit pudding\':3, \'sugar
You can update your code with regex word boundary:
mydictionary = {'yummy tim tam':3, 'milk':2, 'chocolates':5, 'biscuit pudding':3, 'sugar':2}
recipes_book = "For today's lesson we will show you how to make biscuit pudding using yummy tim tam milk and rawsugar"
searcher = re.compile(r'{}'.format("|".join(map(lambda x: r'\b{}\b'.format(x), mydictionary.keys()))), flags=re.I | re.S)
for match in searcher.findall(recipes_book):
print(match)
Output:
biscuit pudding
yummy tim tam
milk