-
Notifications
You must be signed in to change notification settings - Fork 1
/
Simplify.py
62 lines (48 loc) · 1.18 KB
/
Simplify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
## categories
meat = (
'beef',
'chicken',
'turkey',
'lamb',
'pork',
'sausage'
)
fruit = (
'apple',
'pear',
'orange'
)
lactose = (
'milk',
'cream',
'cheese',
'yogurt'
)
categories = {meat,fruit,lactose}
dictionary = dict()
#for category in categories:
# dictionary.update(dict.fromkeys(category,))
dictionary = dict.fromkeys(meat,'meat')
dictionary.update(dict.fromkeys(fruit, 'fruit'))
dictionary.update(dict.fromkeys(lactose, 'lactose'))
#dictionary.update(dict.fromkeys(fruit, 'fruit'))
def match(ingredient , category):
print (ingredient)
ingredient = " ".join((ingredient.replace(" ","")).split(" "))
print (ingredient)
for words in ingredient:
if(dictionary.get(ingredient,ingredient)==category):
return 1
return 0
def simplifyMenu(menuString):
result = ",".join(menuString).split(",")
result = " and ".join(result).split(" and ")
result = "with".join(result).split("with")
result = "with".join(result).split("with")
for entry in result:
entry = entry.strip()
return result
if(match(" apple sunday ","fruit")):
print("match!")
else:
print("no match!")