Bug 207057 Division by zero in UCDET.DLL

r=smontagu sr=rbs
This commit is contained in:
timeless%mozdev.org 2005-11-02 16:56:58 +00:00
Родитель 0ca4f2bb17
Коммит c11846f789
1 изменённых файлов: 12 добавлений и 13 удалений

Просмотреть файл

@ -44,26 +44,25 @@
#include "EUCTWFreq.tab"
#include "GB2312Freq.tab"
#define SURE_YES ((float)0.99)
#define SURE_NO ((float)0.01)
#define SURE_YES 0.99f
#define SURE_NO 0.01f
//return confidence base on received data
float CharDistributionAnalysis::GetConfidence()
{
float r;
//if we didn't receive any character in our consideration range, return negative answer
if (mTotalChars <= 0)
return SURE_NO;
if (mTotalChars > 0)
{
r = mFreqChars / (float)(mTotalChars - mFreqChars) / mTypicalDistributionRatio;
//normalize confidence, (and we don't want to be 100% sure)
if (r >= (float)1.00)
r = SURE_YES;
}
else //if we didn't receive any character in our consideration range, return negative answer
r = SURE_NO;
if (mTotalChars != mFreqChars) {
float r = mFreqChars / ((mTotalChars - mFreqChars) * mTypicalDistributionRatio);
if (r < SURE_YES)
return r;
}
//normalize confidence, (we don't want to be 100% sure)
return SURE_YES;
}
EUCTWDistributionAnalysis::EUCTWDistributionAnalysis()
{