that_language 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/that_language/detect.rb +6 -2
- data/lib/that_language/result.rb +1 -1
- data/lib/that_language/result_set.rb +4 -1
- data/lib/that_language/version.rb +1 -1
- 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: 98adc3d50c5db166ed67999b80c33c57b591f62a
|
4
|
+
data.tar.gz: eee7118251bc0fd2ff3ff406c49d62290bf164c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57460596ffd60c2c2bd69c17c1088e39db6de20e820ef7e20b8a3ae3021c5ee420009882e463da1f13d07fca095a05c615873c61230a52432cd4defdabdb6578
|
7
|
+
data.tar.gz: 792b5f984d2d14c234a2d7fcdbd0e397ab7405532949032b7e38b81a0a72506ff37b8fd99ef0f756d00950ea90a429bc839eef768d468a7e68fbb01134effeb0
|
data/lib/that_language/detect.rb
CHANGED
@@ -10,7 +10,7 @@ module ThatLanguage
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def language(text)
|
13
|
-
|
13
|
+
detect(text).language
|
14
14
|
end
|
15
15
|
|
16
16
|
def language_code(text)
|
@@ -28,7 +28,11 @@ module ThatLanguage
|
|
28
28
|
|
29
29
|
words.each do |word|
|
30
30
|
word_result = lookup_context.normalized(word)
|
31
|
-
word_result.each
|
31
|
+
word_result.each do |language_code, value|
|
32
|
+
next unless value > 0
|
33
|
+
|
34
|
+
result_set.for(language_code).add(value)
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
result_set
|
data/lib/that_language/result.rb
CHANGED
@@ -2,6 +2,9 @@ module ThatLanguage
|
|
2
2
|
class ResultSet
|
3
3
|
include Enumerable
|
4
4
|
|
5
|
+
# TODO: Handle no result in a better way (NullObject anyone?)
|
6
|
+
NO_RESULT = Result.new(language_code: nil)
|
7
|
+
|
5
8
|
def initialize(words_count)
|
6
9
|
@words_count = words_count
|
7
10
|
end
|
@@ -11,7 +14,7 @@ module ThatLanguage
|
|
11
14
|
end
|
12
15
|
|
13
16
|
def winner
|
14
|
-
results.max
|
17
|
+
results.max || NO_RESULT
|
15
18
|
end
|
16
19
|
|
17
20
|
def results
|