Class: CharDet::CharDistributionAnalysis
- Inherits:
-
Object
- Object
- CharDet::CharDistributionAnalysis
show all
- Defined in:
- lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of CharDistributionAnalysis.
36
37
38
39
40
41
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb', line 36
def initialize
@_mCharToFreqOrder = nil @_mTableSize = nil @_mTypicalDistributionRatio = nil reset()
end
|
Instance Method Details
#feed(aStr, aCharLen) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb', line 50
def feed(aStr, aCharLen)
if aCharLen == 2
order = get_order(aStr)
else
order = -1
end
if order >= 0
@_mTotalChars += 1
if order < @_mTableSize
if 512 > @_mCharToFreqOrder[order]
@_mFreqChars += 1
end
end
end
end
|
#get_confidence ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb', line 69
def get_confidence
if @_mTotalChars <= 0
return SURE_NO
end
if @_mTotalChars != @_mFreqChars
r = @_mFreqChars / ((@_mTotalChars - @_mFreqChars) * @_mTypicalDistributionRatio)
if r < SURE_YES
return r
end
end
return SURE_YES
end
|
#get_order(aStr) ⇒ Object
93
94
95
96
97
98
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb', line 93
def get_order(aStr)
return -1
end
|
#got_enough_data ⇒ Object
87
88
89
90
91
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb', line 87
def got_enough_data
return @_mTotalChars > ENOUGH_DATA_THRESHOLD
end
|
43
44
45
46
47
48
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb', line 43
def reset
@_mDone = false @_mTotalChars = 0 @_mFreqChars = 0 end
|