little-recipe-parser 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/grocery_list_formatter.rb +68 -20
- data/lib/parse.rb +8 -4
- data/little-recipe-parser.gemspec +3 -3
- data/test/test_grocery_list_formatter.rb +1 -0
- data/test/test_parse.rb +62 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bcf39f1c8c7134ad340b504b93038f99cee98851
|
|
4
|
+
data.tar.gz: f5eff3c1c7070ad3995b3acf72ec5a5e3a2e39be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8df8df1df4721c96274b6ccd383ae42ba2fab564e09c3e034e5e13e027165716b05698949525f4be0361c03d424a960ab0f84e4b6ab284c27e43826a8a8f576e
|
|
7
|
+
data.tar.gz: eae05a7c96de60b69bb79646ad11bd799c5fede6b7067e95983ecdf126bd8a0c0b4bfb79263ec730b69be2dad465a59f810ed8e1f99945839e51bb61334a8412
|
data/README.md
CHANGED
data/Rakefile
CHANGED
|
@@ -19,8 +19,8 @@ Jeweler::Tasks.new do |gem|
|
|
|
19
19
|
gem.license = "MIT"
|
|
20
20
|
gem.summary = "Recipe Parsing Gem"
|
|
21
21
|
gem.description = "Recipe Parsing Gem - Simply run result = LittleRecipeParser::Parse.new('1 pound of chicken') - you can then call result.quantity, result.tag or result.measurement on the string"
|
|
22
|
-
gem.email = "rrgayhart@gmail.com"
|
|
23
|
-
gem.authors = ["Meeka"]
|
|
22
|
+
gem.email = ["rrgayhart@gmail.com", "navyosu@gmail.com"]
|
|
23
|
+
gem.authors = ["Meeka Gayhart", "Billy Griffin"]
|
|
24
24
|
# dependencies defined in Gemfile
|
|
25
25
|
end
|
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.2
|
|
@@ -23,12 +23,13 @@ class LittleRecipeParser::GroceryListFormatter
|
|
|
23
23
|
['Allspice',
|
|
24
24
|
'Salt and Pepper',
|
|
25
25
|
'Black Peppercorn',
|
|
26
|
+
'Black Pepper',
|
|
26
27
|
'Arrowroot starch',
|
|
27
28
|
'Basil',
|
|
28
29
|
'Bay Leaves',
|
|
29
30
|
'Chili Powder',
|
|
30
31
|
'Cinnamon',
|
|
31
|
-
'Garlic',
|
|
32
|
+
'Garlic Cloves',
|
|
32
33
|
'Red Wine Vinegar',
|
|
33
34
|
'Coriander',
|
|
34
35
|
'Cream of tartar',
|
|
@@ -87,7 +88,6 @@ class LittleRecipeParser::GroceryListFormatter
|
|
|
87
88
|
'Ketchup',
|
|
88
89
|
'Mayonnaise',
|
|
89
90
|
'Mustard',
|
|
90
|
-
'Olive Oil',
|
|
91
91
|
'Peanut Butter',
|
|
92
92
|
'Salad Dressing',
|
|
93
93
|
'Salsa',
|
|
@@ -96,8 +96,9 @@ class LittleRecipeParser::GroceryListFormatter
|
|
|
96
96
|
'Worcestershire',
|
|
97
97
|
'Dairy',
|
|
98
98
|
'Butter',
|
|
99
|
-
'Cheese',
|
|
99
|
+
'Parmesan Cheese',
|
|
100
100
|
'Cottage Cheese',
|
|
101
|
+
'Swiss Cheese',
|
|
101
102
|
'Cream',
|
|
102
103
|
'Cream Cheese',
|
|
103
104
|
'Eggs',
|
|
@@ -107,25 +108,29 @@ class LittleRecipeParser::GroceryListFormatter
|
|
|
107
108
|
'Yogurt',
|
|
108
109
|
'Watercress',
|
|
109
110
|
'Coffee',
|
|
110
|
-
'Soda Pop',
|
|
111
|
-
'Sports Drinks',
|
|
112
|
-
'Tea',
|
|
113
111
|
'French Fries',
|
|
114
112
|
'Frozen Vegetables',
|
|
115
113
|
'Ice Cream',
|
|
116
114
|
'Pizza',
|
|
117
|
-
'Pasta',
|
|
118
|
-
'Rice',
|
|
115
|
+
'Pasta Sauce',
|
|
116
|
+
'White Rice',
|
|
117
|
+
'Brown Rice',
|
|
119
118
|
'Spaghetti Sauce',
|
|
120
119
|
'Meats',
|
|
121
|
-
'Beef',
|
|
120
|
+
'Ground Beef',
|
|
122
121
|
'Pork Loin',
|
|
123
|
-
'Chicken',
|
|
122
|
+
'Chicken Breast',
|
|
123
|
+
'Chicken Thigh',
|
|
124
|
+
'Chicken Wing',
|
|
125
|
+
'Chicken Stock',
|
|
126
|
+
'Chicken Broth',
|
|
127
|
+
'Chicken Drumstick',
|
|
128
|
+
'Chicken Leg',
|
|
124
129
|
'Fish',
|
|
125
|
-
'
|
|
130
|
+
'Frozen Mixed Vegetables',
|
|
126
131
|
'Apple',
|
|
127
132
|
'Asparagus',
|
|
128
|
-
'
|
|
133
|
+
'Banana',
|
|
129
134
|
'Berries',
|
|
130
135
|
'Broccoli',
|
|
131
136
|
'Cabbage',
|
|
@@ -138,7 +143,7 @@ class LittleRecipeParser::GroceryListFormatter
|
|
|
138
143
|
'Lemons',
|
|
139
144
|
'Bacon',
|
|
140
145
|
'Lettuce',
|
|
141
|
-
'Lime',
|
|
146
|
+
'Lime Juice',
|
|
142
147
|
'Melons',
|
|
143
148
|
'Mushrooms',
|
|
144
149
|
'Nectarines',
|
|
@@ -149,21 +154,51 @@ class LittleRecipeParser::GroceryListFormatter
|
|
|
149
154
|
'Plums',
|
|
150
155
|
'Cornstarch',
|
|
151
156
|
'Rice Wine Vinegar',
|
|
152
|
-
'
|
|
153
|
-
'
|
|
157
|
+
'Sesame Oil',
|
|
158
|
+
'Hoisin Sauce',
|
|
154
159
|
'Scallion',
|
|
155
|
-
'Tomato',
|
|
160
|
+
'Tomato Sauce',
|
|
156
161
|
'Bean Sprouts',
|
|
157
162
|
'Tofu',
|
|
158
|
-
'Tuna',
|
|
159
|
-
'
|
|
163
|
+
'Tuna Steak',
|
|
164
|
+
'Light Tuna',
|
|
165
|
+
'White Tuna',
|
|
166
|
+
'Cashew',
|
|
167
|
+
'Walnut',
|
|
168
|
+
'Almond',
|
|
169
|
+
'Extra-virgin Olive Oil',
|
|
170
|
+
'Radish',
|
|
171
|
+
'Lemon Zest',
|
|
172
|
+
'Lemon Wedge',
|
|
173
|
+
'Worcester Sauce',
|
|
174
|
+
'Fresh Cilantro',
|
|
175
|
+
'Hot Dog',
|
|
176
|
+
'American Cheese',
|
|
177
|
+
'Cheddar Cheese',
|
|
178
|
+
'Shallot',
|
|
179
|
+
'Apricot Preserves',
|
|
180
|
+
'Red-wine Vinegar',
|
|
181
|
+
'Ground Pork',
|
|
182
|
+
'Plantain',
|
|
183
|
+
'Red Lentils',
|
|
184
|
+
'Whole Milk',
|
|
185
|
+
'Vegetable Bouillon',
|
|
186
|
+
'Panko Breadcrumbs'
|
|
160
187
|
]
|
|
161
188
|
end
|
|
162
189
|
|
|
163
190
|
def self.secondary
|
|
164
191
|
[
|
|
165
|
-
'Salt',
|
|
192
|
+
'Salt ',
|
|
193
|
+
'Wasabi',
|
|
194
|
+
'Noodle',
|
|
195
|
+
'Garlic',
|
|
166
196
|
'Cloves',
|
|
197
|
+
'Lentils',
|
|
198
|
+
'Avocado',
|
|
199
|
+
'Apricot',
|
|
200
|
+
'Lime',
|
|
201
|
+
'Bouillon',
|
|
167
202
|
'Pepper',
|
|
168
203
|
'Pork',
|
|
169
204
|
'Juice',
|
|
@@ -171,7 +206,20 @@ class LittleRecipeParser::GroceryListFormatter
|
|
|
171
206
|
'Syrup',
|
|
172
207
|
'Ginger',
|
|
173
208
|
'Beans',
|
|
174
|
-
'
|
|
209
|
+
'Tomato',
|
|
210
|
+
'Water',
|
|
211
|
+
'Tuna',
|
|
212
|
+
'Olive Oil',
|
|
213
|
+
'Lemon',
|
|
214
|
+
'Rice',
|
|
215
|
+
'Chicken',
|
|
216
|
+
'Vinegar',
|
|
217
|
+
'Cheese',
|
|
218
|
+
'Pasta Sauce',
|
|
219
|
+
'Beef',
|
|
220
|
+
'Cilantro',
|
|
221
|
+
'Red Wine',
|
|
222
|
+
'White Wine'
|
|
175
223
|
]
|
|
176
224
|
end
|
|
177
225
|
end
|
data/lib/parse.rb
CHANGED
|
@@ -3,7 +3,7 @@ class LittleRecipeParser::Parse
|
|
|
3
3
|
|
|
4
4
|
def initialize(string)
|
|
5
5
|
@raw_ingredient = string
|
|
6
|
-
@tag =
|
|
6
|
+
@tag = get_tag
|
|
7
7
|
@measurement = get_measurement
|
|
8
8
|
@quantity = get_quantity
|
|
9
9
|
end
|
|
@@ -12,6 +12,10 @@ class LittleRecipeParser::Parse
|
|
|
12
12
|
false
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def get_tag
|
|
16
|
+
LittleRecipeParser::GroceryListFormatter.check_name(raw_ingredient)
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def get_quantity
|
|
16
20
|
qtys = raw_ingredient[0..8].split.select do |char|
|
|
17
21
|
char =~ /[[:digit:]]/
|
|
@@ -29,7 +33,7 @@ class LittleRecipeParser::Parse
|
|
|
29
33
|
|
|
30
34
|
def get_measurement
|
|
31
35
|
measurements = acceptable_measurements.select do |measure|
|
|
32
|
-
raw_ingredient.downcase.include?(measure.downcase)
|
|
36
|
+
raw_ingredient[0..20].downcase.include?(measure.downcase)
|
|
33
37
|
end
|
|
34
38
|
if measurements.any?
|
|
35
39
|
answer = measurements.first.strip
|
|
@@ -40,7 +44,7 @@ class LittleRecipeParser::Parse
|
|
|
40
44
|
|
|
41
45
|
def check_secondary_measurements
|
|
42
46
|
secondary_measurements.select do |measure|
|
|
43
|
-
raw_ingredient.downcase.include?(measure.downcase)
|
|
47
|
+
raw_ingredient[0..20].downcase.include?(measure.downcase)
|
|
44
48
|
end.first.try(:strip)
|
|
45
49
|
end
|
|
46
50
|
|
|
@@ -51,7 +55,7 @@ class LittleRecipeParser::Parse
|
|
|
51
55
|
end
|
|
52
56
|
|
|
53
57
|
def secondary_measurements
|
|
54
|
-
['strip', 'strips', 'package', 'can ', 'cans', 'bunch ', 'bunches']
|
|
58
|
+
['strip', 'strips', 'package', 'can ', 'cans', 'bunch ', 'bunches', 'slice', 'slices', 'cube', 'cubes']
|
|
55
59
|
end
|
|
56
60
|
|
|
57
61
|
end
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "little-recipe-parser"
|
|
8
|
-
s.version = "0.1.
|
|
8
|
+
s.version = "0.1.2"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
-
s.authors = ["Meeka"]
|
|
11
|
+
s.authors = ["Meeka Gayhart", "Billy Griffin"]
|
|
12
12
|
s.date = "2014-02-16"
|
|
13
13
|
s.description = "Recipe Parsing Gem - Simply run result = LittleRecipeParser::Parse.new('1 pound of chicken') - you can then call result.quantity, result.tag or result.measurement on the string"
|
|
14
|
-
s.email = "rrgayhart@gmail.com"
|
|
14
|
+
s.email = ["rrgayhart@gmail.com", "navyosu@gmail.com"]
|
|
15
15
|
s.extra_rdoc_files = [
|
|
16
16
|
"LICENSE.txt",
|
|
17
17
|
"README.md"
|
|
@@ -15,6 +15,7 @@ class GroceryListFormatterTest < Test::Unit::TestCase
|
|
|
15
15
|
assert_equal "Fresh Ginger", check_name('1-inch (3cm) piece fresh ginger, peeled and minced')
|
|
16
16
|
assert_equal "Powdered Ginger", check_name('1-inch tsp powdered ginger')
|
|
17
17
|
assert_equal "Tofu", check_name("1 (12 ounce) package soft tofu, drained and cut into 1/2-inch cubes")
|
|
18
|
+
assert_equal "Banana", check_name("2 cup bananas")
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
should "it handles odd pluralization" do
|
data/test/test_parse.rb
CHANGED
|
@@ -19,6 +19,12 @@ class ParseTest < Test::Unit::TestCase
|
|
|
19
19
|
assert_equal 'package', method_measurement('1 (12 ounce) package soft tofu, drained and cut into 1/2-inch cubes')
|
|
20
20
|
assert_equal 'cans', method_measurement('2 (6 ounce) cans tuna, drained')
|
|
21
21
|
assert_equal 'bunch', method_measurement('1 bunch watercress, chopped')
|
|
22
|
+
assert_equal 'Extra-virgin Olive Oil', method_tag('Extra-virgin olive oil')
|
|
23
|
+
assert_equal 'Pasta Sauce', method_tag('26 ounce jar marinara or pasta sauce')
|
|
24
|
+
assert_equal 'Parmesan Cheese', method_tag("1/4 cup Parmesan Cheese")
|
|
25
|
+
assert_equal 'Chicken Broth', method_tag("3/4 cup fat-free, less-sodium chicken broth")
|
|
26
|
+
assert_equal 'tablespoon', method_measurement("2 tablespoon vegetable oil")
|
|
27
|
+
assert_equal nil, method_measurement("5 hot dogs (preferably Oscar Meyer wieners), cut into 1/4” slices")
|
|
22
28
|
end
|
|
23
29
|
|
|
24
30
|
should 'it handles quantity edge cases' do
|
|
@@ -26,6 +32,57 @@ class ParseTest < Test::Unit::TestCase
|
|
|
26
32
|
assert_equal '2', method_quantity('2 (6 ounce) cans tuna, drained')
|
|
27
33
|
end
|
|
28
34
|
|
|
35
|
+
should 'handle a sauce' do
|
|
36
|
+
assert_equal '1', method_quantity("1 teaspoon Worcester sauce")
|
|
37
|
+
assert_equal 'teaspoon', method_measurement("1 teaspoon Worcester sauce")
|
|
38
|
+
assert_equal 'Worcester Sauce', method_tag("1 teaspoon Worcester sauce")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
should 'handle tomato sauce' do
|
|
42
|
+
assert_equal '1', method_quantity("1 teaspoon Tomato sauce")
|
|
43
|
+
assert_equal 'teaspoon', method_measurement("1 teaspoon Tomato sauce")
|
|
44
|
+
assert_equal 'Tomato Sauce', method_tag("1 teaspoon Tomato sauce")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
should 'handle basic vinegar' do
|
|
48
|
+
assert_equal 'Vinegar', method_tag("1 teaspoon Vinegar")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
should 'handle tuna steaks' do
|
|
52
|
+
assert_equal '2', method_quantity("2 pounds tuna steaks, about 2 inches thick")
|
|
53
|
+
assert_equal 'pounds', method_measurement("2 pounds tuna steaks, about 2 inches thick")
|
|
54
|
+
assert_equal 'Tuna Steak', method_tag("2 pounds tuna steaks, about 2 inches thick")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
should 'handle strips' do
|
|
58
|
+
assert_equal '6', method_quantity("6 strips (2 by 1 inch) lemon zest")
|
|
59
|
+
assert_equal 'strip', method_measurement("6 strips (2 by 1 inch) lemon zest")
|
|
60
|
+
assert_equal 'Lemon Zest', method_tag("6 strips (2 by 1 inch) lemon zest")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
should 'handle rice' do
|
|
64
|
+
assert_equal 'White Rice', method_tag("2 cups brown or white rice")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
should 'handle mixed veggies' do
|
|
68
|
+
assert_equal 'Frozen Mixed Vegetables', method_tag('2 cups frozen mixed vegetables')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
should 'handle chicken' do
|
|
72
|
+
assert_equal 'Chicken Breast', method_tag("2 large chicken breasts, cooked and shredded")
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
should 'handle slices of cheese' do
|
|
76
|
+
assert_equal 'Swiss Cheese', method_tag('8 slices Swiss cheese')
|
|
77
|
+
assert_equal 'slice', method_measurement('8 slices Swiss cheese')
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
should 'handle hidden pounts' do
|
|
81
|
+
assert_equal '6', method_quantity("6 green plantains, peeled and cut into 1-inch pieces (about 3 pounds)")
|
|
82
|
+
assert_equal nil, method_measurement("6 green plantains, peeled and cut into 1-inch pieces (about 3 pounds)")
|
|
83
|
+
assert_equal 'Plantain', method_tag("6 green plantains, peeled and cut into 1-inch pieces (about 3 pounds)")
|
|
84
|
+
end
|
|
85
|
+
|
|
29
86
|
def method_measurement(string)
|
|
30
87
|
parse = LittleRecipeParser::Parse.new(string)
|
|
31
88
|
parse.get_measurement
|
|
@@ -36,4 +93,9 @@ class ParseTest < Test::Unit::TestCase
|
|
|
36
93
|
parse.get_quantity
|
|
37
94
|
end
|
|
38
95
|
|
|
96
|
+
def method_tag(string)
|
|
97
|
+
parse = LittleRecipeParser::Parse.new(string)
|
|
98
|
+
parse.get_tag
|
|
99
|
+
end
|
|
100
|
+
|
|
39
101
|
end
|
metadata
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: little-recipe-parser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Meeka
|
|
7
|
+
- Meeka Gayhart
|
|
8
|
+
- Billy Griffin
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
@@ -97,7 +98,9 @@ dependencies:
|
|
|
97
98
|
description: Recipe Parsing Gem - Simply run result = LittleRecipeParser::Parse.new('1
|
|
98
99
|
pound of chicken') - you can then call result.quantity, result.tag or result.measurement
|
|
99
100
|
on the string
|
|
100
|
-
email:
|
|
101
|
+
email:
|
|
102
|
+
- rrgayhart@gmail.com
|
|
103
|
+
- navyosu@gmail.com
|
|
101
104
|
executables: []
|
|
102
105
|
extensions: []
|
|
103
106
|
extra_rdoc_files:
|