1/* -*- C++ -*-
2 SPDX-FileCopyrightText: 1998 Netscape Communications Corporation <developer@mozilla.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#include "JpCntx.h"
8
9namespace kencodingprober
10{
11// This is hiragana 2-char sequence table, the number in each cell represents its frequency category
12const char jp2CharContext[83][83] = {
13 {
14 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
15 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
16 },
17 {
18 2, 4, 0, 4, 0, 3, 0, 4, 0, 3, 4, 4, 4, 2, 4, 3, 3, 4, 3, 2, 3, 3, 4, 2, 3, 3, 3, 2, 4, 1, 4, 3, 3, 1, 5, 4, 3, 4, 3, 4, 3, 5,
19 3, 0, 3, 5, 4, 2, 0, 3, 1, 0, 3, 3, 0, 3, 3, 0, 1, 1, 0, 4, 3, 0, 3, 3, 0, 4, 0, 2, 0, 3, 5, 5, 5, 5, 4, 0, 4, 1, 0, 3, 4,
20 },
21 {
22 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
23 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
24 },
25 {
26 0, 4, 0, 5, 0, 5, 0, 4, 0, 4, 5, 4, 4, 3, 5, 3, 5, 1, 5, 3, 4, 3, 4, 4, 3, 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5, 0, 4, 0, 3, 0, 4, 3, 3, 3, 2, 1, 0, 3, 0, 0, 3, 3,
340 },
341 {
342 0, 4, 0, 3, 0, 3, 0, 3, 0, 3, 5, 5, 3, 3, 3, 3, 4, 3, 4, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 4, 3, 5, 3, 3, 1, 3, 2, 4, 5, 5, 5, 5,
343 4, 3, 4, 5, 5, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 1, 2, 3, 2, 4, 3, 3, 3, 4, 0, 4, 0, 2, 0, 4, 3, 2, 2, 1, 2, 0, 3, 0, 0, 4, 1,
344 },
345};
346
347#define MINIMUM_DATA_THRESHOLD 4
348
349void JapaneseContextAnalysis::HandleData(const char *aBuf, unsigned int aLen)
350{
351 if (mDone) {
352 return;
353 }
354
355 // The buffer we got is byte oriented, and a character may span in more than one
356 // buffers. In case the last one or two byte in last buffer is not complete, we
357 // record how many byte needed to complete that character and skip these bytes here.
358 // We can choose to record those bytes as well and analyze the character once it
359 // is complete, but since a character will not make much difference, by simply skipping
360 // this character will simply our logic and improve performance.
361 for (unsigned int i = mNeedToSkipCharNum; i < aLen;) {
362 unsigned int charLen;
363 const int order = GetOrder(str: aBuf + i, charLen: &charLen);
364 i += charLen;
365 if (i > aLen) {
366 mNeedToSkipCharNum = i - aLen;
367 mLastCharOrder = -1;
368 } else {
369 if (order != -1 && mLastCharOrder != -1) {
370 mTotalRel++;
371 if (mTotalRel > MAX_REL_THRESHOLD) {
372 mDone = true;
373 break;
374 }
375 mRelSample[(int)jp2CharContext[mLastCharOrder][order]]++;
376 }
377 mLastCharOrder = order;
378 }
379 }
380
381 return;
382}
383
384void JapaneseContextAnalysis::Reset(void)
385{
386 mTotalRel = 0;
387 for (unsigned int i = 0; i < NUM_OF_CATEGORY; i++) {
388 mRelSample[i] = 0;
389 }
390 mNeedToSkipCharNum = 0;
391 mLastCharOrder = -1;
392 mDone = false;
393}
394#define DONT_KNOW (float)-1
395
396float JapaneseContextAnalysis::GetConfidence()
397{
398 // This is just one way to calculate confidence. It works well for me.
399 if (mTotalRel > MINIMUM_DATA_THRESHOLD) {
400 return ((float)(mTotalRel - mRelSample[0])) / mTotalRel;
401 } else {
402 return (float)DONT_KNOW;
403 }
404}
405
406int SJISContextAnalysis::GetOrder(const char *str, unsigned int *charLen)
407{
408 // find out current char's byte length
409 if (((unsigned char)*str >= (unsigned char)0x81 && (unsigned char)*str <= (unsigned char)0x9f)
410 || ((unsigned char)*str >= (unsigned char)0xe0 && (unsigned char)*str <= (unsigned char)0xfc)) {
411 *charLen = 2;
412 } else {
413 *charLen = 1;
414 }
415
416 // return its order if it is hiragana
417 if (*str == '\202' //
418 && (unsigned char)*(str + 1) >= (unsigned char)0x9f //
419 && (unsigned char)*(str + 1) <= (unsigned char)0xf1) {
420 return (unsigned char)*(str + 1) - (unsigned char)0x9f;
421 }
422 return -1;
423}
424
425int EUCJPContextAnalysis::GetOrder(const char *str, unsigned int *charLen)
426{
427 // find out current char's byte length
428 if ((unsigned char)*str == (unsigned char)0x8e //
429 || ((unsigned char)*str >= (unsigned char)0xa1 //
430 && (unsigned char)*str <= (unsigned char)0xfe)) {
431 *charLen = 2;
432 } else if ((unsigned char)*str == (unsigned char)0x8f) {
433 *charLen = 3;
434 } else {
435 *charLen = 1;
436 }
437
438 // return its order if it is hiragana
439 if ((unsigned char)*str == (unsigned char)0xa4 //
440 && (unsigned char)*(str + 1) >= (unsigned char)0xa1 //
441 && (unsigned char)*(str + 1) <= (unsigned char)0xf3) {
442 return (unsigned char)*(str + 1) - (unsigned char)0xa1;
443 }
444 return -1;
445}
446}
447

source code of kcodecs/src/probers/JpCntx.cpp