7#include "nsSBCharSetProber.h"
11namespace kencodingprober
13nsProbingState nsSingleByteCharSetProber::HandleData(
const char *aBuf,
unsigned int aLen)
15 for (
unsigned int i = 0; i < aLen; i++) {
16 const unsigned char order = mModel->charToOrderMap[(
unsigned char)aBuf[i]];
18 if (order < SYMBOL_CAT_ORDER) {
21 if (order < SAMPLE_SIZE) {
24 if (mLastOrder < SAMPLE_SIZE) {
27 ++(mSeqCounters[(int)mModel->precedenceMatrix[mLastOrder * SAMPLE_SIZE + order]]);
29 ++(mSeqCounters[(int)mModel->precedenceMatrix[order * SAMPLE_SIZE + mLastOrder]]);
36 if (mState == eDetecting) {
37 if (mTotalSeqs > SB_ENOUGH_REL_THRESHOLD) {
38 float cf = GetConfidence();
39 if (cf > POSITIVE_SHORTCUT_THRESHOLD) {
41 }
else if (cf < NEGATIVE_SHORTCUT_THRESHOLD) {
50void nsSingleByteCharSetProber::Reset(
void)
54 for (
unsigned int i = 0; i < NUMBER_OF_SEQ_CAT; i++) {
64float nsSingleByteCharSetProber::GetConfidence(
void)
66#ifdef NEGATIVE_APPROACH
68 if (mTotalSeqs > mSeqCounters[NEGATIVE_CAT] * 10) {
69 return ((
float)(mTotalSeqs - mSeqCounters[NEGATIVE_CAT] * 10)) / mTotalSeqs * mFreqChar / mTotalChar;
76 r = ((float)1.0) * mSeqCounters[POSITIVE_CAT] / mTotalSeqs / mModel->mTypicalPositiveRatio;
77 r = r * mFreqChar / mTotalChar;
78 if (r >= (
float)1.00) {
87const char *nsSingleByteCharSetProber::GetCharSetName()
90 return mModel->charsetName;
92 return mNameProber->GetCharSetName();
96void nsSingleByteCharSetProber::DumpStatus()
98 printf(
" SBCS: %1.3f [%s]\r\n", GetConfidence(), GetCharSetName());
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:52 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.