NjxCreateDic Function

Description

This function writes dictionary header information into the specified user dictionary or learning dictionary and initializes the dictionary. To allocate memory for these dictionaries, you must specify the dictionary handle and its size.

Syntax

#include <mw/iwnn/iwnnCTR.h>

s16 NjxCreateDic(
     IWNN_DIC_HANDLE  handle,                     // Dictionary handle
     const  IWNN_CLASS* iwnn,                     // Parsing information class
     s8  type,                                    // Dictionary type
     u32  size                                    // Dictionary byte size
);

Parameters

NameDescription
IN / OUT IWNN_DIC_HANDLE handle The dictionary handle of a user dictionary or learning dictionary. An error results if NULL is specified.
IN const IWNN_CLASS* iwnn Parsing information class. An error results if NULL is specified.
IN u8 type Dictionary type
   NJ_CREATE_DIC_TYPE_USER: User dictionary
   NJ_CREATE_DIC_TYPE_LEARN_AWNN: Learning dictionary-AWnn type-
   NJ_CREATE_DIC_TYPE_LEARN: Learning dictionary-iWnn type-
   NJ_CREATE_DIC_TYPE_USER_ADDITIONAL: User dictionary (with additional information)
   NJ_CREATE_DIC_TYPE_LEARN_ADDITIONAL: Learning dictionary-iWnn type- (with additional information)
IN u32 size Byte size of the memory specified by handle.
The user dictionary is fixed to either NJ_USER_DIC_SIZE (dictionary without additional information) or NJ_USER2_DIC_SIZE (dictionary with additional information). A learning structure having the specified size is created for a learning dictionary. An error results if there is not enough memory to be initialized as a dictionary.

Return Values

s16 Non-negative value: Normal exit
Negative value: Error

Errors

Error Codes Description of Error
NJ_ERR_PARAM_ENVIRONMENT_NULL A NULL pointer was specified for iwnn.
NJ_ERR_DIC_HANDLE_NULL NULL was set in handle.
NJ_ERR_CREATE_TYPE_INVALID A value other than 0, 1, or 2 was specified in type.
NJ_ERR_AREA_SIZE_INVALID   ■ A value less than the minimum size required to create a dictionary was set in size.
  ■ A value exceeding the 256 KB queue size is specified in size.

With iWnn, writing to the learning memory area and word registration memory area is done in u16 (2-byte) units to accommodate recovery processing. Warnings are therefore sometimes output when compiling this system. To create a dictionary memory region, assign an even start address to the dictionary handle specified for the function. Depending on the system, a bus error might occur if the specified dictionary handle is assigned to an odd address.

Size of the User and Learning Dictionaries, and the Number of Entries

Size of the user dictionary and number of registered entries

User dictionary size (NJ_USER_DIC_SIZE) is calculated using:
  ■ The maximum length of a reading string to be registered as a single word in the user dictionary (NJ_MAX_USER_LEN)
  ■ The maximum length of a candidate registered as a single word in the user dictionary (NJ_MAX_USER_CANDIDATE_LEN)
  ■ The maximum number of registered entries in the user dictionary (NJ_MAX_USER_COUNT)

Header region 80 Bytes
Memory per registered entry Maximum reading string length registered as a word in the user dictionary * sizeof(wchar_t)
+ Maximum candidate string length registered as a word in the user dictionary * sizeof(wchar_t)
+ 9 Bytes

For example, when using UTF-16BE, if the maximum reading string length to be registered as a word in the user dictionary (NJ_MAX_USER_LEN) and the maximum string length for a candidate registered as a word in the user dictionary (NJ_MAX_USER_CANDIDATE_LEN) are both 30, and the maximum number of words registered in the user dictionary (NJ_MAX_USER_COUNT) is 100, then the following amount of memory is required:
  80 + ((30 * 2) + (30 * 2) + 9) * 100 = 12980 Bytes

Size of the user dictionary (with additional information) and number of registered entries

User dictionary size (NJ_USER2_DIC_SIZE) is calculated using:
  ■ The maximum length of a reading string to be registered as a word in the user dictionary (NJ_MAX_USER_LEN)
  ■ The maximum length of a candidate string registered as a word in the user dictionary (NJ_MAX_USER_CANDIDATE_LEN)
  ■ The maximum length of the additional information string registered as a word in the user dictionary (NJ_MAX_ADDITIONAL_LEN)
■ The maximum number of registered entries in the user dictionary (NJ_MAX_USER_COUNT)

Header region 80 Bytes
Memory per registered entry Maximum reading string length registered as a word in the user dictionary * sizeof(wchar_t)
+ Maximum candidate string length registered as a word in the user dictionary * sizeof(wchar_t)
+ Maximum additional information string registered as a word in the user dictionary * sizeof(wchar_t)
+ 9 Bytes

For example, when using UTF-16BE, if the maximum reading string length to be registered as a word in the user dictionary (NJ_MAX_USER_LEN), the maximum string length for a candidate registered as a word in the user dictionary (NJ_MAX_USER_CANDIDATE_LEN), and the maximum length of an additional information string registered as a word in the user dictionary (NJ_MAX_ADDITIONAL_LEN) are all 30, and the maximum number of words registered in the user dictionary (NJ_MAX_USER_COUNT) is 100, then the following amount of memory is required:
  80 + ((30 * 2) + (30 * 2) + 9) * 100 = 18980 bytes

Learning region size and number of registerable entries

The size of the learning dictionary depends on the maximum number of registered phrases.

-iWnn type-
Header region 80 Bytes
Memory per registered entry 42 Bytes

If making 1000 registrations (maximum of 1000 phrases), the memory required is given by: 80 + (42 * 1000) = 42080 Bytes

-iWnn Type- (with additional information)
Header region 80 Bytes
Memory per registered entry 44 + maximum additional information string length * sizeof(wchar_t) Bytes

If making 1000 registrations (maximum of 1000 phrases), the memory required is:
80 + (84 * 1000) = 84080 bytes Note: If the maximum additional information string length is 40

-AWNN Type-
Header region 80 Bytes
Memory per registered entry 36 Bytes

If making 1000 registrations (maximum of 1000 phrases), the memory required is given by:
80 + (36 * 1000) = 36080 Bytes

In the case of both types, phrase-level learning for a single registration area is possible for phrases where the reading length plus candidate length of that single phrase fits within 27 bytes. If the reading length plus candidate length of the single phrase exceeds 27 bytes, phrase-level learning uses multiple 27-byte registration areas because registration uses memory in 27-byte increments.

Due to the specifications of prediction conversion and kana-kanji conversion, the number of learned words that can be used is given by the maximum number of entries that can be registered in the learning dictionary minus the maximum conversion candidate string (NJ_MAX_RESULT_LEN). Given a learning dictionary capable of registering up to 1000 words (phrases) and a maximum conversion candidate string length of 55 characters, the number of learned words (phrases) that can be used is:
1000 - 55 = 945

CONFIDENTIAL