#include <nsEUCJPProber.h>
Public Member Functions | |
nsEUCJPProber (void) | |
virtual | ~nsEUCJPProber (void) |
nsProbingState | HandleData (const char *aBuf, PRUint32 aLen) |
const char * | GetCharSetName () |
nsProbingState | GetState (void) |
void | Reset (void) |
float | GetConfidence (void) |
void | SetOpion () |
Protected Attributes | |
nsCodingStateMachine * | mCodingSM |
nsProbingState | mState |
EUCJPContextAnalysis | mContextAnalyser |
EUCJPDistributionAnalysis | mDistributionAnalyser |
char | mLastChar [2] |
Definition at line 51 of file nsEUCJPProber.h.
nsEUCJPProber::nsEUCJPProber | ( | void | ) | [inline] |
Definition at line 51 of file nsEUCJPProber.h.
00051 : public nsCharSetProber { 00052 public:
virtual nsEUCJPProber::~nsEUCJPProber | ( | void | ) | [inline, virtual] |
Definition at line 53 of file nsEUCJPProber.h.
References EUCJPSMModel, mCodingSM, and Reset().
00053 {mCodingSM = new nsCodingStateMachine(&EUCJPSMModel);
const char* nsEUCJPProber::GetCharSetName | ( | ) | [inline, virtual] |
Implements nsCharSetProber.
Definition at line 55 of file nsEUCJPProber.h.
References mCodingSM.
00055 {delete mCodingSM;};
float nsEUCJPProber::GetConfidence | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 97 of file nsEUCJPProber.cpp.
References CharDistributionAnalysis::GetConfidence(), JapaneseContextAnalysis::GetConfidence(), mContextAnalyser, and mDistributionAnalyser.
Referenced by HandleData().
00098 { 00099 float contxtCf = mContextAnalyser.GetConfidence(); 00100 float distribCf = mDistributionAnalyser.GetConfidence(); 00101 00102 return (contxtCf > distribCf ? contxtCf : distribCf); 00103 }
nsProbingState nsEUCJPProber::GetState | ( | void | ) | [inline, virtual] |
Implements nsCharSetProber.
Definition at line 56 of file nsEUCJPProber.h.
nsProbingState nsEUCJPProber::HandleData | ( | const char * | aBuf, | |
PRUint32 | aLen | |||
) | [virtual] |
Implements nsCharSetProber.
Definition at line 53 of file nsEUCJPProber.cpp.
References eDetecting, eError, eFoundIt, eItsMe, eNotMe, eStart, GetConfidence(), nsCodingStateMachine::GetCurrentCharLen(), JapaneseContextAnalysis::GotEnoughData(), CharDistributionAnalysis::HandleOneChar(), JapaneseContextAnalysis::HandleOneChar(), mCodingSM, mContextAnalyser, 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 mContextAnalyser.HandleOneChar(mLastChar, charLen); 00078 mDistributionAnalyser.HandleOneChar(mLastChar, charLen); 00079 } 00080 else 00081 { 00082 mContextAnalyser.HandleOneChar(aBuf+i-1, charLen); 00083 mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); 00084 } 00085 } 00086 } 00087 00088 mLastChar[0] = aBuf[aLen-1]; 00089 00090 if (mState == eDetecting) 00091 if (mContextAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) 00092 mState = eFoundIt; 00093 00094 return mState; 00095 }
void nsEUCJPProber::Reset | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 45 of file nsEUCJPProber.cpp.
References eDetecting, mCodingSM, mContextAnalyser, mDistributionAnalyser, mState, CharDistributionAnalysis::Reset(), JapaneseContextAnalysis::Reset(), and nsCodingStateMachine::Reset().
Referenced by ~nsEUCJPProber().
00046 { 00047 mCodingSM->Reset(); 00048 mState = eDetecting; 00049 mContextAnalyser.Reset(); 00050 mDistributionAnalyser.Reset(); 00051 }
void nsEUCJPProber::SetOpion | ( | ) | [inline, virtual] |
nsCodingStateMachine* nsEUCJPProber::mCodingSM [protected] |
Definition at line 59 of file nsEUCJPProber.h.
Referenced by GetCharSetName(), HandleData(), Reset(), and ~nsEUCJPProber().
EUCJPContextAnalysis nsEUCJPProber::mContextAnalyser [protected] |
Definition at line 65 of file nsEUCJPProber.h.
Referenced by GetConfidence(), HandleData(), and Reset().
Definition at line 66 of file nsEUCJPProber.h.
Referenced by GetConfidence(), HandleData(), and Reset().
char nsEUCJPProber::mLastChar[2] [protected] |
Definition at line 68 of file nsEUCJPProber.h.
Referenced by HandleData().
nsProbingState nsEUCJPProber::mState [protected] |
Definition at line 63 of file nsEUCJPProber.h.
Referenced by HandleData(), and Reset().