food_ingredient_parser 1.1.3 → 1.1.4
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/lib/food_ingredient_parser/loose/transform/amount_from_name.treetop +3 -2
- data/lib/food_ingredient_parser/strict/grammar/amount.treetop +4 -0
- data/lib/food_ingredient_parser/strict/grammar/common.treetop +7 -2
- data/lib/food_ingredient_parser/strict/grammar/ingredient_simple.treetop +3 -2
- data/lib/food_ingredient_parser/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 64b65447c4e16dadb986f1422cc02449e7050858
|
|
4
|
+
data.tar.gz: 94842b54aa5701e384c6fc3e35a3b8d03ca9b978
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b91f77676d5edab883e89701f9b1a2e6659ad8ef655080314d0f23cedf9afc79b20cb1e3ae93504e17cda5dbd710501fb00b9b4cb581e2020d11671ca094b696
|
|
7
|
+
data.tar.gz: c2afb010c5b967dc411f52645231fb36465346aad0f937461bf1b51fa2e198afe60973570abff2d35cbc5f8b2c3d2fe4151ee90b70bc4e3ad33513648ab2e03c
|
|
@@ -5,8 +5,9 @@ module FoodIngredientParser::Loose::Transform
|
|
|
5
5
|
|
|
6
6
|
rule amount_from_name
|
|
7
7
|
# just amount, amount in front or at the end
|
|
8
|
-
ws* amount:amount
|
|
9
|
-
ws* amount:
|
|
8
|
+
ws* amount:amount ws+ name:(.*) /
|
|
9
|
+
ws* amount:amount_simple_percent ws* name:(.*) /
|
|
10
|
+
ws* amount:amount ws* /
|
|
10
11
|
ws* name:( !amount word ( ws+ !amount word )* )+ ws* amount:amount ws*
|
|
11
12
|
end
|
|
12
13
|
end
|
|
@@ -9,6 +9,10 @@ module FoodIngredientParser::Strict::Grammar
|
|
|
9
9
|
amount:amount_simple <AmountNode>
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
rule amount_simple_percent
|
|
13
|
+
amount:(amount_simple_number ws* percent) <AmountNode>
|
|
14
|
+
end
|
|
15
|
+
|
|
12
16
|
rule amount_simple
|
|
13
17
|
( (
|
|
14
18
|
'of which'i / 'at least'i / 'minimal'i / 'maximal'i / 'less than'i / 'more than'i /
|
|
@@ -10,7 +10,7 @@ module FoodIngredientParser::Strict::Grammar
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
rule char
|
|
13
|
-
[[:alnum:]] /
|
|
13
|
+
!mark [[:alnum:]] /
|
|
14
14
|
fraction /
|
|
15
15
|
[-/\`'´’+=_{}&] /
|
|
16
16
|
[®™] /
|
|
@@ -51,6 +51,11 @@ module FoodIngredientParser::Strict::Grammar
|
|
|
51
51
|
( 'and' / 'en' / 'und' ) !char / '&'
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
rule e_number
|
|
55
|
+
( 'E'i '-'? [0-9] [0-9] [0-9] [[:alpha:]]? )
|
|
56
|
+
![[:alnum:]] / ( ws* '(' 'i'i+ ')' ) # e.g. "E450 (iii)"
|
|
57
|
+
end
|
|
58
|
+
|
|
54
59
|
rule abbrev
|
|
55
60
|
# These are listed explicitely to avoid incorrect interpretations, and allow missing trailing dots.
|
|
56
61
|
# To get an idea of what occurs (second one omits trailing dots):
|
|
@@ -124,7 +129,7 @@ module FoodIngredientParser::Strict::Grammar
|
|
|
124
129
|
'L(+)-' [[:alnum:]]+ /
|
|
125
130
|
'L.' ws+ 'rhamnosus'i / 'L.' ws+ 'acidophilus'i / 'L.' ws+ 'casei' / 'B.'i ws+ 'lactis'i / 'A.'i ws+ 'oryzae'i /
|
|
126
131
|
'type'i ws+ '"' [0-9]+ '"' /
|
|
127
|
-
|
|
132
|
+
e_number
|
|
128
133
|
) ![[:alpha:]]
|
|
129
134
|
end
|
|
130
135
|
end
|
|
@@ -9,13 +9,14 @@ module FoodIngredientParser::Strict::Grammar
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
rule ingredient_simple_with_amount
|
|
12
|
-
pre:( '{' ws* )? amount:amount
|
|
12
|
+
pre:( '{' ws* )? amount:amount ws+ ing:ingredient_simple <IngredientNode> /
|
|
13
|
+
pre:( '{' ws* )? amount:amount_simple_percent ws* ing:ingredient_simple <IngredientNode> /
|
|
13
14
|
ing:ingredient_simple ws* amount:amount post:( ws* '}' )? (ws? mark:mark)? <IngredientNode> /
|
|
14
15
|
ing:ingredient_simple <IngredientNode>
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
rule ingredient_simple_e_number
|
|
18
|
-
name:
|
|
19
|
+
name:e_number <IngredientNode>
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: food_ingredient_parser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- wvengen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-10-
|
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: treetop
|