#include <nsEUCKRProber.h>
Public Member Functions | |
nsEUCKRProber (void) | |
virtual | ~nsEUCKRProber (void) |
nsProbingState | HandleData (const char *aBuf, PRUint32 aLen) |
const char * | GetCharSetName () |
nsProbingState | GetState (void) |
void | Reset (void) |
float | GetConfidence (void) |
void | SetOpion () |
Protected Member Functions | |
void | GetDistribution (PRUint32 aCharLen, const char *aStr) |
Protected Attributes | |
nsCodingStateMachine * | mCodingSM |
nsProbingState | mState |
EUCKRDistributionAnalysis | mDistributionAnalyser |
char | mLastChar [2] |
Definition at line 45 of file nsEUCKRProber.h.
nsEUCKRProber::nsEUCKRProber | ( | void | ) | [inline] |
Definition at line 47 of file nsEUCKRProber.h.
References EUCKRSMModel, mCodingSM, and Reset().
00047 {mCodingSM = new nsCodingStateMachine(&EUCKRSMModel); 00048 Reset();};
virtual nsEUCKRProber::~nsEUCKRProber | ( | void | ) | [inline, virtual] |
const char* nsEUCKRProber::GetCharSetName | ( | ) | [inline, virtual] |
Implements nsCharSetProber.
Definition at line 51 of file nsEUCKRProber.h.
float nsEUCKRProber::GetConfidence | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 90 of file nsEUCKRProber.cpp.
References CharDistributionAnalysis::GetConfidence(), and mDistributionAnalyser.
Referenced by HandleData().
00091 { 00092 float distribCf = mDistributionAnalyser.GetConfidence(); 00093 00094 return (float)distribCf; 00095 }
void nsEUCKRProber::GetDistribution | ( | PRUint32 | aCharLen, | |
const char * | aStr | |||
) | [protected] |
nsProbingState nsEUCKRProber::GetState | ( | void | ) | [inline, virtual] |
Implements nsCharSetProber.
Definition at line 52 of file nsEUCKRProber.h.
References mState.
00052 {return mState;};
nsProbingState nsEUCKRProber::HandleData | ( | const char * | aBuf, | |
PRUint32 | aLen | |||
) | [virtual] |
Implements nsCharSetProber.
Definition at line 48 of file nsEUCKRProber.cpp.
References eDetecting, eError, eFoundIt, eItsMe, eNotMe, eStart, GetConfidence(), nsCodingStateMachine::GetCurrentCharLen(), CharDistributionAnalysis::GotEnoughData(), CharDistributionAnalysis::HandleOneChar(), mCodingSM, mDistributionAnalyser, mLastChar, mState, nsCodingStateMachine::NextState(), and SHORTCUT_THRESHOLD.
00049 { 00050 nsSMState codingState; 00051 00052 for (PRUint32 i = 0; i < aLen; i++) 00053 { 00054 codingState = mCodingSM->NextState(aBuf[i]); 00055 if (codingState == eError) 00056 { 00057 mState = eNotMe; 00058 break; 00059 } 00060 if (codingState == eItsMe) 00061 { 00062 mState = eFoundIt; 00063 break; 00064 } 00065 if (codingState == eStart) 00066 { 00067 PRUint32 charLen = mCodingSM->GetCurrentCharLen(); 00068 00069 if (i == 0) 00070 { 00071 mLastChar[1] = aBuf[0]; 00072 mDistributionAnalyser.HandleOneChar(mLastChar, charLen); 00073 } 00074 else 00075 mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); 00076 } 00077 } 00078 00079 mLastChar[0] = aBuf[aLen-1]; 00080 00081 if (mState == eDetecting) 00082 if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) 00083 mState = eFoundIt; 00084 // else 00085 // mDistributionAnalyser.HandleData(aBuf, aLen); 00086 00087 return mState; 00088 }
void nsEUCKRProber::Reset | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 40 of file nsEUCKRProber.cpp.
References eDetecting, mCodingSM, mDistributionAnalyser, mState, CharDistributionAnalysis::Reset(), and nsCodingStateMachine::Reset().
Referenced by nsEUCKRProber().
00041 { 00042 mCodingSM->Reset(); 00043 mState = eDetecting; 00044 mDistributionAnalyser.Reset(); 00045 //mContextAnalyser.Reset(); 00046 }
void nsEUCKRProber::SetOpion | ( | ) | [inline, virtual] |
nsCodingStateMachine* nsEUCKRProber::mCodingSM [protected] |
Definition at line 60 of file nsEUCKRProber.h.
Referenced by HandleData(), nsEUCKRProber(), Reset(), and ~nsEUCKRProber().
Definition at line 64 of file nsEUCKRProber.h.
Referenced by GetConfidence(), HandleData(), and Reset().
char nsEUCKRProber::mLastChar[2] [protected] |
Definition at line 65 of file nsEUCKRProber.h.
Referenced by HandleData().
nsProbingState nsEUCKRProber::mState [protected] |
Definition at line 61 of file nsEUCKRProber.h.
Referenced by GetState(), HandleData(), and Reset().