7#include "nsSBCSGroupProber.h"
9#include "UnicodeGroupProber.h"
10#include "nsHebrewProber.h"
11#include "nsSBCharSetProber.h"
16namespace kencodingprober
18nsSBCSGroupProber::nsSBCSGroupProber()
20 mProbers[0] =
new nsSingleByteCharSetProber(&Win1251Model);
21 mProbers[1] =
new nsSingleByteCharSetProber(&Koi8rModel);
22 mProbers[2] =
new nsSingleByteCharSetProber(&Latin5Model);
23 mProbers[3] =
new nsSingleByteCharSetProber(&MacCyrillicModel);
24 mProbers[4] =
new nsSingleByteCharSetProber(&Ibm866Model);
25 mProbers[5] =
new nsSingleByteCharSetProber(&Ibm855Model);
26 mProbers[6] =
new nsSingleByteCharSetProber(&Latin7Model);
27 mProbers[7] =
new nsSingleByteCharSetProber(&Win1253Model);
28 mProbers[8] =
new nsSingleByteCharSetProber(&Latin5BulgarianModel);
29 mProbers[9] =
new nsSingleByteCharSetProber(&Win1251BulgarianModel);
31 nsHebrewProber *hebprober =
new nsHebrewProber();
34 mProbers[10] = hebprober;
35 mProbers[11] =
new nsSingleByteCharSetProber(&Win1255Model,
false, hebprober);
36 mProbers[12] =
new nsSingleByteCharSetProber(&Win1255Model,
true, hebprober);
37 mProbers[13] =
new UnicodeGroupProber();
40 if (mProbers[10] && mProbers[11] && mProbers[12]) {
41 hebprober->SetModelProbers(mProbers[11], mProbers[12]);
43 for (
unsigned int i = 10; i <= 12; ++i) {
45 mProbers[i] =
nullptr;
57nsSBCSGroupProber::~nsSBCSGroupProber()
59 for (
unsigned int i = 0; i < NUM_OF_SBCS_PROBERS; i++) {
64const char *nsSBCSGroupProber::GetCharSetName()
67 if (mBestGuess == -1) {
76 return mProbers[mBestGuess]->GetCharSetName();
79void nsSBCSGroupProber::Reset(
void)
82 for (
unsigned int i = 0; i < NUM_OF_SBCS_PROBERS; i++) {
95nsProbingState nsSBCSGroupProber::HandleData(
const char *aBuf,
unsigned int aLen)
99 char *newBuf1 =
nullptr;
100 unsigned int newLen1 = 0;
108 if (!FilterWithoutEnglishLetters(aBuf, aLen, &newBuf1, newLen1)) {
116 for (i = 0; i < NUM_OF_SBCS_PROBERS; ++i) {
120 st = mProbers[i]->HandleData(newBuf1, newLen1);
121 if (st == eFoundIt) {
125 }
else if (st == eNotMe) {
126 mIsActive[i] =
false;
128 if (mActiveNum == 0) {
141float nsSBCSGroupProber::GetConfidence(
void)
144 float bestConf = 0.0;
153 for (i = 0; i < NUM_OF_SBCS_PROBERS; ++i) {
157 cf = mProbers[i]->GetConfidence();
168void nsSBCSGroupProber::DumpStatus()
173 cf = GetConfidence();
174 printf(
" SBCS Group Prober --------begin status \r\n");
175 for (i = 0; i < NUM_OF_SBCS_PROBERS; i++) {
177 printf(
" inactive: [%s] (i.e. confidence is too low).\r\n", mProbers[i]->GetCharSetName());
179 mProbers[i]->DumpStatus();
182 printf(
" SBCS Group found best match [%s] confidence %f.\r\n", mProbers[mBestGuess]->GetCharSetName(), cf);