Class: CharDet::HebrewProber
- Inherits:
-
CharSetProber
show all
- Defined in:
- lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb
Instance Attribute Summary
#active
Instance Method Summary
collapse
#filter_high_bit_only, #filter_with_english_letters, #filter_without_english_letters, #get_confidence
Constructor Details
Returns a new instance of HebrewProber.
151
152
153
154
155
156
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb', line 151
def initialize
super()
@_mLogicalProber = nil
@_mVisualProber = nil
reset()
end
|
Instance Method Details
#feed(aBuf) ⇒ Object
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb', line 192
def feed(aBuf)
if get_state() == ENotMe
return ENotMe
end
aBuf = filter_high_bit_only(aBuf)
for cur in aBuf.split(' ')
if cur == ' '
if @_mBeforePrev != ' '
if is_final(@_mPrev)
@_mFinalCharLogicalScore += 1
elsif is_non_final(@_mPrev)
@_mFinalCharVisualScore += 1
end
end
else
if (@_mBeforePrev == ' ') and (is_final(@_mPrev)) and (cur != ' ')
@_mFinalCharVisualScore += 1
end
end
@_mBeforePrev = @_mPrev
@_mPrev = cur
end
return EDetecting
end
|
#get_charset_name ⇒ Object
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb', line 252
def get_charset_name
finalsub = @_mFinalCharLogicalScore - @_mFinalCharVisualScore
if finalsub >= MIN_FINAL_CHAR_DISTANCE
return LOGICAL_HEBREW_NAME
end
if finalsub <= -MIN_FINAL_CHAR_DISTANCE
return VISUAL_HEBREW_NAME
end
modelsub = @_mLogicalProber.get_confidence() - @_mVisualProber.get_confidence()
if modelsub > MIN_MODEL_DISTANCE
return LOGICAL_HEBREW_NAME
end
if modelsub < -MIN_MODEL_DISTANCE
return VISUAL_HEBREW_NAME
end
if finalsub < 0.0
return VISUAL_HEBREW_NAME
end
return LOGICAL_HEBREW_NAME
end
|
#get_state ⇒ Object
281
282
283
284
285
286
287
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb', line 281
def get_state
if (@_mLogicalProber.get_state() == ENotMe) and (@_mVisualProber.get_state() == ENotMe)
return ENotMe
end
return EDetecting
end
|
#is_final(c) ⇒ Object
174
175
176
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb', line 174
def is_final(c)
return [FINAL_KAF, FINAL_MEM, FINAL_NUN, FINAL_PE, FINAL_TSADI].include?(c)
end
|
#is_non_final(c) ⇒ Object
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb', line 178
def is_non_final(c)
return [NORMAL_KAF, NORMAL_MEM, NORMAL_NUN, NORMAL_PE].include?(c)
end
|
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb', line 158
def reset
@_mFinalCharLogicalScore = 0
@_mFinalCharVisualScore = 0
@_mPrev = ' '
@_mBeforePrev = ' '
end
|
#set_model_probers(logicalProber, visualProber) ⇒ Object
169
170
171
172
|
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb', line 169
def set_model_probers(logicalProber, visualProber)
@_mLogicalProber = logicalProber
@_mVisualProber = visualProber
end
|