rlid 0.1.1 → 0.1.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.
@@ -1,7 +1,7 @@
1
1
  require 'rlid/language_guesser/naive_bayes_guesser'
2
2
 
3
3
  module Rlid
4
- @guesser = SmartBayesGuesser.new
4
+ @guesser = NaiveBayesProbabilityGuesser.new
5
5
  def self.guess_language(string)
6
6
  @guesser.guess_language(string)
7
7
  end
@@ -6,11 +6,11 @@ require 'rlid/probabilities/language_probabilities'
6
6
 
7
7
  class NaiveBayesGuesser < LanguageGuesser
8
8
  def initialize(default=1)
9
- print "Naive Bayes: loading models.."
9
+ #print "Naive Bayes: loading models.."
10
10
  @models = NaiveBayesModels.load
11
11
  @models.default_count = default
12
12
  @name = "Naive Bayes"
13
- puts " Done!"
13
+ #puts " Done!"
14
14
  end
15
15
 
16
16
  def guess_language(string)
@@ -49,6 +49,7 @@ class NaiveBayesProbabilityGuesser < NaiveBayesGuesser
49
49
  end
50
50
  end
51
51
 
52
+ =begin
52
53
  class SmartBayesGuesser < LanguageGuesser
53
54
  def initialize(default=1)
54
55
  #print "Smart Bayes: loading models.."
@@ -65,6 +66,7 @@ class SmartBayesGuesser < LanguageGuesser
65
66
  LanguageProbabilities.new(results)
66
67
  end
67
68
  end
69
+ =end
68
70
 
69
71
 
70
72
  class NaiveBayesPriorGuesser < NaiveBayesProbabilityGuesser
@@ -176,7 +176,7 @@ private
176
176
  end
177
177
  end
178
178
 
179
-
179
+ =begin
180
180
  class SmartBayesModels
181
181
  def initialize
182
182
  @trigrams = NaiveBayesModels.load
@@ -200,5 +200,6 @@ class SmartBayesModels
200
200
  res
201
201
  end
202
202
  end
203
+ =end
203
204
 
204
205
  end # module Rlid
@@ -74,6 +74,10 @@ class LanguageProbabilities
74
74
  @percentage[lang]
75
75
  end
76
76
 
77
+ def to_a
78
+ sorted.map{|x| {language: x[LANG], confidence: x[PERC]}}
79
+ end
80
+
77
81
  def first
78
82
  sorted.first[LANG]
79
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rlid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,7 +43,7 @@ require_paths:
43
43
  required_ruby_version: !ruby/object:Gem::Requirement
44
44
  none: false
45
45
  requirements:
46
- - - ! '>='
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
48
  version: 1.9.1
49
49
  required_rubygems_version: !ruby/object:Gem::Requirement