#include <nsGB2312Prober.h>
Public Member Functions | |
nsGB18030Prober (void) | |
virtual | ~nsGB18030Prober (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 |
GB2312DistributionAnalysis | mDistributionAnalyser |
char | mLastChar [2] |
Definition at line 47 of file nsGB2312Prober.h.
nsGB18030Prober::nsGB18030Prober | ( | void | ) | [inline] |
Definition at line 49 of file nsGB2312Prober.h.
References GB18030SMModel, mCodingSM, and Reset().
00049 {mCodingSM = new nsCodingStateMachine(&GB18030SMModel); 00050 Reset();};
virtual nsGB18030Prober::~nsGB18030Prober | ( | void | ) | [inline, virtual] |
const char* nsGB18030Prober::GetCharSetName | ( | ) | [inline, virtual] |
Implements nsCharSetProber.
Definition at line 53 of file nsGB2312Prober.h.
float nsGB18030Prober::GetConfidence | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 95 of file nsGB2312Prober.cpp.
References CharDistributionAnalysis::GetConfidence(), and mDistributionAnalyser.
Referenced by HandleData().
00096 { 00097 float distribCf = mDistributionAnalyser.GetConfidence(); 00098 00099 return (float)distribCf; 00100 }
void nsGB18030Prober::GetDistribution | ( | PRUint32 | aCharLen, | |
const char * | aStr | |||
) | [protected] |
nsProbingState nsGB18030Prober::GetState | ( | void | ) | [inline, virtual] |
Implements nsCharSetProber.
Definition at line 54 of file nsGB2312Prober.h.
References mState.
00054 {return mState;};
nsProbingState nsGB18030Prober::HandleData | ( | const char * | aBuf, | |
PRUint32 | aLen | |||
) | [virtual] |
Implements nsCharSetProber.
Definition at line 53 of file nsGB2312Prober.cpp.
References eDetecting, eError, eFoundIt, eItsMe, eNotMe, eStart, GetConfidence(), nsCodingStateMachine::GetCurrentCharLen(), CharDistributionAnalysis::GotEnoughData(), CharDistributionAnalysis::HandleOneChar(), mCodingSM, mDistributionAnalyser, mLastChar, mState, nsCodingStateMachine::NextState(), and SHORTCUT_THRESHOLD.
00054 { 00055 nsSMState codingState; 00056 00057 for (PRUint32 i = 0; i < aLen; i++) 00058 { 00059 codingState = mCodingSM->NextState(aBuf[i]); 00060 if (codingState == eError) 00061 { 00062 mState = eNotMe; 00063 break; 00064 } 00065 if (codingState == eItsMe) 00066 { 00067 mState = eFoundIt; 00068 break; 00069 } 00070 if (codingState == eStart) 00071 { 00072 PRUint32 charLen = mCodingSM->GetCurrentCharLen(); 00073 00074 if (i == 0) 00075 { 00076 mLastChar[1] = aBuf[0]; 00077 mDistributionAnalyser.HandleOneChar(mLastChar, charLen); 00078 } 00079 else 00080 mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); 00081 } 00082 } 00083 00084 mLastChar[0] = aBuf[aLen-1]; 00085 00086 if (mState == eDetecting) 00087 if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) 00088 mState = eFoundIt; 00089 // else 00090 // mDistributionAnalyser.HandleData(aBuf, aLen); 00091 00092 return mState; 00093 }
void nsGB18030Prober::Reset | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 45 of file nsGB2312Prober.cpp.
References eDetecting, mCodingSM, mDistributionAnalyser, mState, CharDistributionAnalysis::Reset(), and nsCodingStateMachine::Reset().
Referenced by nsGB18030Prober().
00046 { 00047 mCodingSM->Reset(); 00048 mState = eDetecting; 00049 mDistributionAnalyser.Reset(); 00050 //mContextAnalyser.Reset(); 00051 }
void nsGB18030Prober::SetOpion | ( | ) | [inline, virtual] |
nsCodingStateMachine* nsGB18030Prober::mCodingSM [protected] |
Definition at line 62 of file nsGB2312Prober.h.
Referenced by HandleData(), nsGB18030Prober(), Reset(), and ~nsGB18030Prober().
Definition at line 66 of file nsGB2312Prober.h.
Referenced by GetConfidence(), HandleData(), and Reset().
char nsGB18030Prober::mLastChar[2] [protected] |
Definition at line 67 of file nsGB2312Prober.h.
Referenced by HandleData().
nsProbingState nsGB18030Prober::mState [protected] |
Definition at line 63 of file nsGB2312Prober.h.
Referenced by GetState(), HandleData(), and Reset().