I need to extract specific words from the list of attributes and return all the possible words to a new field with the help of defined dictionaries. (using Python Parser in ArcGIS)
Example
Apples are red in colour
Grapes are green in colour
Grepes are sour in taste
Mangoes are sweet to taste
Mnagoes are yellow in colour
Defined dictionaries:
Mangoes:('Mangoes','Mnagoes')
Grapes: ('Grapes','Grepes')
Expected Output:
Apples,red
Grapes,green
Grapes,sour
Mangoes,sweet
Mangoes,yellow
This is the code i tried with:
def replace(work_name):
if any(x in work_name.lower() for x in ['dam','dem','daem']):
return 'Dam'
elif any(x in work_name.lower() for x in ['pond','pound','talab']):
return 'Farm Pond'
elif any(x in work_name.lower() for x in ['plantation']): return 'Plantation'
else: return 0