food_ingredient_parser 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77503a77f269805d23ecb60a7b9d63401063e140
4
- data.tar.gz: 412d0c6aab0924371677cb8e2a4201349f4684a8
3
+ metadata.gz: 64b65447c4e16dadb986f1422cc02449e7050858
4
+ data.tar.gz: 94842b54aa5701e384c6fc3e35a3b8d03ca9b978
5
5
  SHA512:
6
- metadata.gz: 82ba24e9277917326348e769feda731b030a9f6477f811f067b1ff1377e784d206adc56407a607e5b3498ddbbfcc8751c7ef6b3583490f59fa56771bdd9f0a80
7
- data.tar.gz: '0768160047a661cad810a4fda0c7922e03b039bd17f4aa7b2022722cb636080fa01690a731da8d088861c6981163803b41d2bd577093f4b0a91250d4fe68c03d'
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 ws+ name:(.*) /
9
- ws* amount:amount ws* /
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
- 'E'i '-'? [0-9] [0-9] [0-9] [[:alpha:]]? ws* '(' 'i'i+ ')' # e.g. "E450 (iii)"
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 ws+ ing:ingredient_simple <IngredientNode> /
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:( [Ee] [0-9] [0-9] [0-9] [a-zA-Z]? ) ![a-zA-Z0-9] <IngredientNode>
19
+ name:e_number <IngredientNode>
19
20
  end
20
21
 
21
22
  end
@@ -1,4 +1,4 @@
1
1
  module FoodIngredientParser
2
- VERSION = '1.1.3'
3
- VERSION_DATE = '2018-10-12'
2
+ VERSION = '1.1.4'
3
+ VERSION_DATE = '2018-10-22'
4
4
  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.3
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-12 00:00:00.000000000 Z
11
+ date: 2018-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop