inci_score 3.1.3 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/README.md +14 -50
- data/bin/console +5 -4
- data/bin/inci_score +2 -2
- data/lib/inci_score/cli.rb +18 -19
- data/lib/inci_score/computer.rb +28 -28
- data/lib/inci_score/config.rb +10 -0
- data/lib/inci_score/ingredient.rb +18 -19
- data/lib/inci_score/levenshtein.rb +12 -9
- data/lib/inci_score/normalizer.rb +8 -6
- data/lib/inci_score/normalizer_rules.rb +13 -28
- data/lib/inci_score/recognizer.rb +15 -10
- data/lib/inci_score/recognizer_rules.rb +11 -11
- data/lib/inci_score/refinements.rb +3 -1
- data/lib/inci_score/response.rb +14 -7
- data/lib/inci_score/score.rb +8 -3
- data/lib/inci_score/scorer.rb +20 -13
- data/lib/inci_score/version.rb +3 -1
- data/lib/inci_score.rb +10 -4
- metadata +15 -52
- data/.gitignore +0 -13
- data/.travis.yml +0 -7
- data/Gemfile +0 -4
- data/Rakefile +0 -24
- data/config/catalog.yml +0 -5018
- data/config.ru +0 -3
- data/ext/levenshtein.c +0 -43
- data/inci_score.gemspec +0 -28
- data/lib/inci_score/api.rb +0 -19
- data/lib/inci_score/catalog.rb +0 -13
- data/lib/inci_score/server.rb +0 -51
- data/log/.gitignore +0 -4
data/config.ru
DELETED
data/ext/levenshtein.c
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
static int call(const char* word1, int len1, const char* word2, int len2) {
|
2
|
-
int matrix[len1 + 1][len2 + 1];
|
3
|
-
int i;
|
4
|
-
for (i = 0; i <= len1; i++) {
|
5
|
-
matrix[i][0] = i;
|
6
|
-
}
|
7
|
-
for (i = 0; i <= len2; i++) {
|
8
|
-
matrix[0][i] = i;
|
9
|
-
}
|
10
|
-
for (i = 1; i <= len1; i++) {
|
11
|
-
int j;
|
12
|
-
char c1;
|
13
|
-
|
14
|
-
c1 = word1[i-1];
|
15
|
-
for (j = 1; j <= len2; j++) {
|
16
|
-
char c2;
|
17
|
-
|
18
|
-
c2 = word2[j-1];
|
19
|
-
if (c1 == c2) {
|
20
|
-
matrix[i][j] = matrix[i-1][j-1];
|
21
|
-
}
|
22
|
-
else {
|
23
|
-
int delete;
|
24
|
-
int insert;
|
25
|
-
int substitute;
|
26
|
-
int minimum;
|
27
|
-
|
28
|
-
delete = matrix[i-1][j] + 1;
|
29
|
-
insert = matrix[i][j-1] + 1;
|
30
|
-
substitute = matrix[i-1][j-1] + 1;
|
31
|
-
minimum = delete;
|
32
|
-
if (insert < minimum) {
|
33
|
-
minimum = insert;
|
34
|
-
}
|
35
|
-
if (substitute < minimum) {
|
36
|
-
minimum = substitute;
|
37
|
-
}
|
38
|
-
matrix[i][j] = minimum;
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
return matrix[len1][len2];
|
43
|
-
}
|
data/inci_score.gemspec
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "inci_score/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "inci_score"
|
7
|
-
s.version = InciScore::VERSION
|
8
|
-
s.authors = ["costajob"]
|
9
|
-
s.email = ["costajob@gmail.com"]
|
10
|
-
s.summary = %q{A library that computes the hazard of cosmetic products components, based on the Biodizionario data.}
|
11
|
-
s.homepage = "https://github.com/costajob/inci_score.git"
|
12
|
-
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
13
|
-
s.bindir = "bin"
|
14
|
-
s.executables << "inci_score"
|
15
|
-
s.require_paths = ["lib"]
|
16
|
-
s.license = "MIT"
|
17
|
-
s.required_ruby_version = ">= 2.2.2"
|
18
|
-
|
19
|
-
s.add_runtime_dependency "puma", "~> 3"
|
20
|
-
s.add_runtime_dependency "rack", "~> 2"
|
21
|
-
s.add_runtime_dependency "RubyInline", "~> 3"
|
22
|
-
|
23
|
-
s.add_development_dependency "bundler", "~> 1.11"
|
24
|
-
s.add_development_dependency "rake", "~> 10.0"
|
25
|
-
s.add_development_dependency "minitest", "~> 5.0"
|
26
|
-
s.add_development_dependency "rack-test", "~> 0.6"
|
27
|
-
s.add_development_dependency "benchmark-ips", "~> 2"
|
28
|
-
end
|
data/lib/inci_score/api.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require "rack"
|
2
|
-
require "inci_score"
|
3
|
-
|
4
|
-
module InciScore
|
5
|
-
module Api
|
6
|
-
extend self
|
7
|
-
|
8
|
-
def catalog
|
9
|
-
@catalog ||= Catalog.fetch
|
10
|
-
end
|
11
|
-
|
12
|
-
def call(env)
|
13
|
-
req = Rack::Request.new(env)
|
14
|
-
src = req.params["src"]
|
15
|
-
json = src ? Computer.new(src: src, catalog: catalog).call.to_json : %q({"error": "no valid source"})
|
16
|
-
["200", {"Content-Type" => "application/json"}, [json]]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/inci_score/catalog.rb
DELETED
data/lib/inci_score/server.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require "etc"
|
2
|
-
require "puma/launcher"
|
3
|
-
require "puma/configuration"
|
4
|
-
|
5
|
-
module InciScore
|
6
|
-
class Server
|
7
|
-
RACKUP_FILE = File.expand_path("../../../config.ru", __FILE__)
|
8
|
-
DEFAULT_HOST = "0.0.0.0"
|
9
|
-
CPUs = Etc.nprocessors
|
10
|
-
|
11
|
-
def initialize(port: 9292, threads: "0:#{CPUs*4}", workers: CPUs, preload: false,
|
12
|
-
config_klass: Puma::Configuration, launcher_klass: Puma::Launcher)
|
13
|
-
@port = port
|
14
|
-
@workers = workers
|
15
|
-
@threads = threads.split(":")
|
16
|
-
@preload = preload
|
17
|
-
@config_klass = config_klass
|
18
|
-
@launcher_klass = launcher_klass
|
19
|
-
end
|
20
|
-
|
21
|
-
def run
|
22
|
-
launcher.run
|
23
|
-
end
|
24
|
-
|
25
|
-
private def launcher
|
26
|
-
@launcher_klass.new(config)
|
27
|
-
end
|
28
|
-
|
29
|
-
private def config
|
30
|
-
@config_klass.new do |c|
|
31
|
-
c.rackup RACKUP_FILE
|
32
|
-
c.bind "tcp://#{DEFAULT_HOST}:#{@port}"
|
33
|
-
c.workers @workers if workers?
|
34
|
-
c.threads(*@threads)
|
35
|
-
c.preload_app! if @preload
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
private def workers?
|
40
|
-
@workers > 1 && !java? && !windows?
|
41
|
-
end
|
42
|
-
|
43
|
-
private def java?
|
44
|
-
RUBY_VERSION == "java"
|
45
|
-
end
|
46
|
-
|
47
|
-
private def windows?
|
48
|
-
Gem.win_platform?
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/log/.gitignore
DELETED