Please Help me on that.
- I have a list of stopwords and I have a search list. I want to remove those stop words from the search list.
- After (Step 1), I want to match each split word with Dictionary Values. If Values Match replaces the particular word with corresponding Dictionary Key then join the others words.
So far I have done the Step 1 (see code below). It worked well:
stopwords=['what','hello','and','at','is','am','i']
search_list=['where is north and northern side',
'ask in the community at western environmental',
'my name is alan and i am coming from london southeast']
dictionary = {'n': ['north','northern'],
's': ['south','southern'],
'e': ['east','eastern'],
'w': ['west','western'],
'env': ['environ.','enviornment','environmental']}
result = [' '.join(w for w in place.split() if w.lower() not in stopwords)
for place in search_list]
print (result)
I need the below desirable Final Output to fulfill Step 2. What should I change/include in the above one line of code for getting my desired final output? Any other alternative method also welcome.
['where n n side', 'ask in the community w env', 'my name alan coming from london s']