Ruby >= 1.9 doesn't have jcode #1

Merged
merged 2 commits into from Jul 5, 2011
Jump to file or symbol
Failed to load files and symbols.
+6 −2
Split
View
@@ -1,5 +1,5 @@
require 'yaml'
-require 'jcode'
+require 'jcode' if RUBY_VERSION < '1.9'
$KCODE = 'u' if RUBY_VERSION < '1.9'
class LanguageDetector
@@ -205,7 +205,11 @@ def is_puctuation? b
end
def count_ngram token, n, counts
- token = "_#{token}#{'_' * (n-1)}" if n > 1 && token.jlength >= n
+ if RUBY_VERSION < '1.9'
+ token = "_#{token}#{'_' * (n-1)}" if n > 1 && token.jlength >= n
+ else
+ token = "_#{token}#{'_' * (n-1)}" if n > 1 && token.length >= n
+ end
i = 0
while i + n <= token.length
s = ''