about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/lib/language_detector.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/lib/language_detector.rb b/app/lib/language_detector.rb
index ca5cb2591..1c22a9ccc 100644
--- a/app/lib/language_detector.rb
+++ b/app/lib/language_detector.rb
@@ -6,6 +6,7 @@ class LanguageDetector
   def initialize(text, account = nil)
     @text = text
     @account = account
+    @identifier = CLD3::NNetLanguageIdentifier.new(1, 2048)
   end
 
   def to_iso_s
@@ -15,15 +16,15 @@ class LanguageDetector
   private
 
   def detected_language_code
-    detected_language[:code].to_sym if detected_language_reliable?
+    result.language.to_sym if detected_language_reliable?
   end
 
-  def detected_language
-    @_detected_language ||= CLD.detect_language(text_without_urls)
+  def result
+    @result ||= @identifier.find_language(text_without_urls)
   end
 
   def detected_language_reliable?
-    detected_language[:reliable]
+    result.reliable?
   end
 
   def text_without_urls