7#include "nsHebrewProber.h"
11#define FINAL_KAF ('\xea')
12#define NORMAL_KAF ('\xeb')
13#define FINAL_MEM ('\xed')
14#define NORMAL_MEM ('\xee')
15#define FINAL_NUN ('\xef')
16#define NORMAL_NUN ('\xf0')
17#define FINAL_PE ('\xf3')
18#define NORMAL_PE ('\xf4')
19#define FINAL_TSADI ('\xf5')
20#define NORMAL_TSADI ('\xf6')
24#define MIN_FINAL_CHAR_DISTANCE (5)
28#define MIN_MODEL_DISTANCE (0.01)
30#define VISUAL_HEBREW_NAME ("ISO-8859-8")
31#define LOGICAL_HEBREW_NAME ("windows-1255")
33namespace kencodingprober
35bool nsHebrewProber::isFinal(
char c)
37 return ((c == FINAL_KAF) || (c == FINAL_MEM) || (c == FINAL_NUN) || (c == FINAL_PE) || (c == FINAL_TSADI));
40bool nsHebrewProber::isNonFinal(
char c)
42 return ((c == NORMAL_KAF) || (c == NORMAL_MEM) || (c == NORMAL_NUN) || (c == NORMAL_PE));
80nsProbingState nsHebrewProber::HandleData(
const char *aBuf,
unsigned int aLen)
83 if (GetState() == eNotMe) {
88 const char *endPtr = aBuf + aLen;
90 for (curPtr = (
char *)aBuf; curPtr < endPtr; ++curPtr) {
93 if (mBeforePrev !=
' ') {
95 ++mFinalCharLogicalScore;
96 }
else if (isNonFinal(mPrev)) {
97 ++mFinalCharVisualScore;
101 if ((mBeforePrev ==
' ') && (isFinal(mPrev)) && (cur !=
' ')) {
102 ++mFinalCharVisualScore;
114const char *nsHebrewProber::GetCharSetName()
117 int finalsub = mFinalCharLogicalScore - mFinalCharVisualScore;
118 if (finalsub >= MIN_FINAL_CHAR_DISTANCE) {
119 return LOGICAL_HEBREW_NAME;
121 if (finalsub <= -(MIN_FINAL_CHAR_DISTANCE)) {
122 return VISUAL_HEBREW_NAME;
126 float modelsub = mLogicalProb->GetConfidence() - mVisualProb->GetConfidence();
127 if (modelsub > MIN_MODEL_DISTANCE) {
128 return LOGICAL_HEBREW_NAME;
130 if (modelsub < -(MIN_MODEL_DISTANCE)) {
131 return VISUAL_HEBREW_NAME;
136 return VISUAL_HEBREW_NAME;
140 return LOGICAL_HEBREW_NAME;
143void nsHebrewProber::Reset(
void)
145 mFinalCharLogicalScore = 0;
146 mFinalCharVisualScore = 0;
154nsProbingState nsHebrewProber::GetState(
void)
157 if ((mLogicalProb->GetState() == eNotMe) && (mVisualProb->GetState() == eNotMe)) {
164void nsHebrewProber::DumpStatus()
166 printf(
" HEB: %d - %d [Logical-Visual score]\r\n", mFinalCharLogicalScore, mFinalCharVisualScore);
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:08 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.