/usr/share/tdiary/bayes/convert.rb is in tdiary-contrib 5.0.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # Copyright (C) 2008, KURODA Hiraku <hiraku@hinet.mydns.jp>
# You can redistribute it and/or modify it under GPL2.
require "bayes"
require "kconv"
module Bayes
module CHARSET
module EUC
KCONV = Kconv::EUC
end
module UTF8
KCONV = Kconv::UTF8
end
end
class FilterBase
def convert_corpus(corpus, to_code, from_code)
r = self.class::Corpus.new
corpus.each do |k, v|
r[k.kconv(to_code::KCONV, from_code::KCONV)] = v
end
r
end
private :convert_corpus
def convert(to_code, from_code)
@charset = to_code
@ham = convert_corpus(@ham, to_code, from_code)
@spam = convert_corpus(@spam, to_code, from_code)
end
end
end
|