I have a dictionary of keys and multiple values as below:
word_list = {'cool':['better','good','best','great'], 'car':['vehicle','moving','automobile','four-wheeler'], 'sound':['noise', 'disturbance', 'rattle']}
sentences = ['that day I heard a vehicle noise not a great four-wheeler', 'the automobile industry is doing good these days', 'that moving noise is better now']
As I have multiple values for a given key, if any of these values appear in the sentences, I want to replace them with its associated key.
I tried the following, but did not get the desired output.
results= [' '.join(word_list.get(y, y) for y in w.split()) for w in sentences]
Desired output:
['that day I heard a car sound not a cool car', 'the car industry is doing cool these days', 'that car sound is better now']
Not sure how to achieve this.