I have defined my dic as follows:
grocery_dict={"apple":"fruite", "pepper": "veg", "spaghetthi":"pasta", "banana":"fruite", "tomato":"fruite"}
and my list is grocery_list=["apple","bananas","pizza","pepper"]
I have written a code that allows me to compare the items and delivers the category of the item.
gl=[]
for item in grocery_list:
if item in grocery_dict:
x=grocery_dict[item]
gl.append(x)
else:
x='other'
gl.append(x)
print(gl)
Next i can caluclate how many times i have each category. Now my issue is how to compare it a part of a word exists in the dictionnary for example if i have items such as "Mexican Pepper" or "tomatto" and how to not consider capital letters in a string.
Another question: Is it possible to use pyspark for such cases?
Thank you in advance