inci_score 4.5.0 → 4.5.2

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
  SHA256:
3
- metadata.gz: 462ec33d1c493272235feaef061ac62822c4dfd6ad6c339e858da8fdfa491894
4
- data.tar.gz: 42f1e47b971185e92d4af19f2fbdee0f363dc9f241041b8ed800230ae9bd0e22
3
+ metadata.gz: 9b62e565ea7191b030ebcdf3b278130065ecb325743bf4ca618e0c8e7d7559a8
4
+ data.tar.gz: 0fcbf56e6edb8a314c202200e89d8f53428b009472440d7a1e92815be90b9df9
5
5
  SHA512:
6
- metadata.gz: cc4f049d56ea9fc60ce92943d7da50c15b697f8712733b409e3327ab73b3c4c0e60d0687f55fcbbefb9f4fd2fdc4c05fe5aa86435f5b75fb558bf456744c9cc4
7
- data.tar.gz: a706360921a1cc36b1b5f1fef53932b859de69a27b02fd8b662b76dc8fe9808e1409779297bfa159c0d57bc6bb1dfb6e5287d4455def84500ce194fa0102706a
6
+ metadata.gz: 7f4040838f05e804090a2482d3b6ea03c1c4575e5133a0989af9f733c373f6c1c507426196fca5eba539c4fbe5c3322a62e623a1630c8ade6dfe2f056a616938
7
+ data.tar.gz: c14b303bae2a60c0f16b1df28e95e77cf2b32caaa33086d8852edf8486dfccbaf29bb361a7d8c2150eb32a569890c84a812369f13bdd38f61df979a76f18abd2
data/README.md CHANGED
@@ -57,7 +57,7 @@ You can include this gem into your own library and start computing the INCI scor
57
57
  require "inci_score"
58
58
 
59
59
  inci = InciScore::Computer.new(src: 'aqua, dimethicone').call
60
- inci.score # 53.76
60
+ inci.score # 56.25
61
61
  ```
62
62
 
63
63
  As you see the results are wrapped by an *InciScore::Response* object, this is useful when dealing with the CLI and HTTP interfaces (read below).
@@ -80,7 +80,7 @@ You can collect INCI data by using the available CLI interface:
80
80
  inci_score --src="ingredients: aqua, dimethicone, pej-10, noent"
81
81
 
82
82
  TOTAL SCORE:
83
- 47.18
83
+ 53.22
84
84
  PRECISION:
85
85
  75.0
86
86
  COMPONENTS:
data/config/catalog.yml CHANGED
@@ -4019,6 +4019,7 @@ prunus avium: 0
4019
4019
  prunus cerasus: 0
4020
4020
  prunus domestica: 0
4021
4021
  prunus dulcis: 0
4022
+ prunus amygdalus dulcis (sweet almond) oil: 0
4022
4023
  prunus persica: 0
4023
4024
  prunus serotina: 0
4024
4025
  prunus spinosa: 0
@@ -4908,6 +4909,7 @@ tripeptide-29: 1
4908
4909
  triphenyl trimethicone: 4
4909
4910
  tripotassium edta: 4
4910
4911
  trisodium edta: 4
4912
+ trisodium ethylenediamine disuccinate: 2
4911
4913
  trisodium hedta: 4
4912
4914
  trisodium lauroampho pg-acetate phosphate chloride: 3
4913
4915
  trisodium methylglycinediacetate: 1
@@ -25,7 +25,7 @@ module InciScore
25
25
  if parenthesis?
26
26
  parenthesis = PARENTHESIS.join
27
27
  parenthesis_values = raw.match(PARENTHESIS_RULE).captures.map { |c| c.delete(parenthesis) }
28
- deparenthesized = raw.sub(PARENTHESIS_RULE, '').sub(/\s+/, ' ').strip
28
+ deparenthesized = raw.sub(PARENTHESIS_RULE, '').sub(/\s{2,}/, ' ').strip
29
29
  [deparenthesized].concat(parenthesis_values)
30
30
  else
31
31
  raw.split(SLASH_RULE).map(&:strip)
@@ -7,7 +7,11 @@ module InciScore
7
7
  module Rules
8
8
  TOLERANCE = 3
9
9
 
10
- Component = Struct.new(:name, :hazard)
10
+ Component = Struct.new(:name, :hazard) do
11
+ def to_s
12
+ "#{name} (#{hazard})"
13
+ end
14
+ end
11
15
 
12
16
  Key = ->(src) do
13
17
  score = Config::CATALOG[src]
@@ -53,7 +57,7 @@ module InciScore
53
57
  def call(src)
54
58
  return if src.size < TOLERANCE
55
59
  digits = src[0, MIN_MEANINGFUL]
56
- pairs = Config::CATALOG.detect { |name, _| name.start_with?(digits) }.to_a.first
60
+ pairs = Config::CATALOG.detect { |name, _| name.start_with?(digits) }
57
61
  Component.new(*pairs) if pairs
58
62
  end
59
63
  end
@@ -41,7 +41,7 @@ PRECISION:
41
41
  return '' if components.empty?
42
42
  %Q{
43
43
  COMPONENTS:
44
- \t#{components.map { |c| "#{c.name} (#{c.hazard})" }.join(', ')}}
44
+ \t#{components.map(&:to_s).join(', ')}}
45
45
  end
46
46
 
47
47
  def unrecognized_str
@@ -40,7 +40,11 @@ module InciScore
40
40
  end
41
41
 
42
42
  def weight(index)
43
- Math.log(index+1, size * WEIGHT_FACTOR)
43
+ Math.log(index + 1, size * ratio(index))
44
+ end
45
+
46
+ def ratio(index)
47
+ WEIGHT_FACTOR / (index + 1)
44
48
  end
45
49
  end
46
50
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InciScore
4
- VERSION = '4.5.0'
4
+ VERSION = '4.5.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inci_score
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - costajob