sentino 0.2.1 → 0.2.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/VERSION +1 -1
- data/lib/sentino/pattern.rb +18 -3
- data/sentino.gemspec +2 -2
- data/test/test_sentino.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e57080c59573aa3c0b0e2fc34007ffeed0d3e6e0
|
4
|
+
data.tar.gz: 76092a3d41038d6d4474885e38e38751fc185a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaec1c17e79368c04f72956168ea526f1a9cd834d01c4c6cc63026a441a956feaede9ec9d460b1b374c4fd554b87ade578c287b73c09c436f4359390ee8762fc
|
7
|
+
data.tar.gz: 45d0f88d26e7cb82ff669a8963a7603d45af7b78c79bf5cf507acecb2d491a40a26d72441d4079997e9b3df8f3d95ab1ad71fcc7470dd519aafcbd4f32ad1e30
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/sentino/pattern.rb
CHANGED
@@ -14,7 +14,10 @@ private
|
|
14
14
|
words = string.split(" ").map{|s| s.downcase}
|
15
15
|
matchings = []
|
16
16
|
for word in words
|
17
|
-
|
17
|
+
if word.length > 3
|
18
|
+
wordgroups = create_matchings(word)
|
19
|
+
matchings << wordgroups
|
20
|
+
end
|
18
21
|
end
|
19
22
|
matchings
|
20
23
|
end
|
@@ -36,9 +39,21 @@ private
|
|
36
39
|
end
|
37
40
|
|
38
41
|
def check(string)
|
42
|
+
checked_words = []
|
39
43
|
counts = []
|
40
|
-
for
|
41
|
-
counts << count_matchings(string, mathcer)
|
44
|
+
for words in @reference
|
45
|
+
#counts << count_matchings(string, mathcer)
|
46
|
+
res = 0
|
47
|
+
words = words.sort_by(&:length).reverse
|
48
|
+
for word in words
|
49
|
+
break if checked_words.include? word
|
50
|
+
res = count_matchings(string, word)
|
51
|
+
if res > 0
|
52
|
+
checked_words << word
|
53
|
+
break
|
54
|
+
end
|
55
|
+
end
|
56
|
+
counts << res
|
42
57
|
end
|
43
58
|
total_length = counts.map{|x| x == 0 ? 1 : x}.reduce(:+)
|
44
59
|
matching_length = counts.reduce(:+)
|
data/sentino.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: sentino 0.2.
|
5
|
+
# stub: sentino 0.2.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "sentino"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
data/test/test_sentino.rb
CHANGED
@@ -32,5 +32,13 @@ class TestSentino < Test::Unit::TestCase
|
|
32
32
|
assert_true sentino.match(obst) < sentino.match(suger)
|
33
33
|
end
|
34
34
|
|
35
|
+
should "give a higher value for roggen then for mohn" do
|
36
|
+
reference = "Brot, Cerealien & Backwaren > Mehl, Getreide & Backzutaten > Getreide > Roggen"
|
37
|
+
mohn = "Lebensmittel Backen Backzutaten Mohn"
|
38
|
+
roggen = "Lebensmittel Mehl Stärke & Co. Mehl & Getreide Roggenmehl"
|
39
|
+
sentino = Sentino::Pattern.new(reference)
|
40
|
+
assert_true sentino.match(mohn) < sentino.match(roggen)
|
41
|
+
end
|
42
|
+
|
35
43
|
|
36
44
|
end
|