-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules.txt
153 lines (91 loc) · 2.69 KB
/
rules.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
7 types of rules
in order of precedence:
capital words are those used to match a pattern
1. hold, do nothing
@hold UNIT SELECTOR
2. renaming
SELECTOR is selector
bean.garbanzo is chickpea
soymilk is milk.soy
(does not apply if query already has a prefix (same or different))
3. addition and removal of properties
UNIT SELECTOR (+ property)
UNIT SELECTOR (- property)
(does not apply if property is already added or removed)
$ chickpea?dry
$ chickpea?!cooked?!uncooked + cooked
4. prefixing
SELECTOR is selector
chickpea is legume
legume is vegetable
5. unit conversion
# UNIT SELECTOR is # unit selector
6. number conversion
@dec UNIT SELECTOR
@frac UNIT SELECTOR
(does not apply if already converted)
7. addition of ingredients
is item & item
rice is $ & sauce.soy
(this will add one unit of soy sauce to the
shopping list for every unit of rice)
1 bowl rice is $ $ $ & 1 tsp sauce.soy
you can omit the unnessessary &
rice is & sauce.soy
1 bowl rice is & 1 tsp sauce.soy
of course, you will likely want a more general formula
1 volume rice is & 0.01 $ sauce.soy
things you can select on:
UNIT
CATEGORY.CATEGORY.CATEGORY?PROPERTY?PROPERTY
UNIT CATEGORY.CATEGORY.CATEGORY?PROPERTY?PROPERTY
can use $ for wildcarding
can use ! to negate a property
The left side can have one of five forms
SELECTOR
UNIT SELECTOR
# UNIT SELECTOR
# SELECTOR
@command UNIT SELECTOR
we can distinguish by the number of words
the second and fourth forms can be distinguished
by if the first word is a valid number
operations
is rename or unit conversion, add a prefix
+ add a property
- remove a property
example
15 fl_oz chickpea + cooked is 1 can
bean.garbanzo is a chickpea
chickpea - cooked - uncooked - dry is + cooked
chickpea + dry is - dry + uncooked
1 volume chickpea + cooked is 1/3 $ $ + cooked - uncooked & 1 $ water - $
renaming, conversion, and prefixing all use "is" operator once
renaming: A is B
conversion: # A is # B
conversion: # A B is # C D
conversion: # A B is # C
prefixing: A (is) a B
search and replace: A (is) (a) synonym (of) B
+ $ keeps all properties, where they would otherwise
be discarded
- $ removes all properties, where they would otherwise be kept
example with units:
1 kg is 1000 g
1 mg is 1/1000 g
g is a mass
100 g carrot is 1 count carrot
declarations
A (assumed to be 1 meals_worth)
# A (assumed to be in count units)
# A B
@import path
priorities
0: hold
1: do nothing, likely meaning property edits, dec, frac
2: renaming, insertion
3: prefixing
4: hold units
5: single and double conversions
@begin multiply #
@end