#include <sent/stddefs.h>
#include <sent/ngram2.h>
マクロ定義 | |
| #define | wrt(A, B, C, D) if (wrtfunc(A,B,C,D) == FALSE) return FALSE |
関数 | |
| void | reset_wrt_counter () |
| static unsigned int | get_wrt_counter () |
| static boolean | wrtfunc (FILE *fp, void *buf, size_t unitbyte, size_t unitnum) |
| Binary write function, with byte swapping if needed. | |
| static boolean | write_header (FILE *fp, char *str) |
| Write header information, with identifier string. | |
| boolean | ngram_write_bin (FILE *fp, NGRAM_INFO *ndata, char *headerstr) |
| Write a whole N-gram data in binary format. | |
変数 | |
| static boolean | need_swap |
| TRUE if need byte swap | |
| static unsigned int | count |
rev.3.5 より,読み込みの高速性を考慮して書き出しのバイトオーダーを Big endian 固定からマシン依存に変更された.またインデックスの 24bit 化 および 2-gram のバックオフデータの圧縮も行うなど,ファイル形式の 内部仕様が一部変更された.これにより,3.5 以降の mkbingram で で生成したバイナリN-gramは, 3.4.2以前の Julius では使えない. (ヘッダチェックでエラーとなる)
なお 3.5 以降の Julius では従来のモデルも問題なく読める.この場合, インデックスの 24bit 化とバックオフの圧縮はモデル読み込み時に その都度行われる.
バイトオーダーに関してヘッダに記述することで,読み込み時に判定して 読み込む.これにより,異なるバイトオーダーのマシンで生成した バイナリN-gramでも問題なく読める.もちろん従来のモデルもそのまま 読み込める.
ngram_write_bin.c で定義されています。
| static boolean wrtfunc | ( | FILE * | fp, | |
| void * | buf, | |||
| size_t | unitbyte, | |||
| size_t | unitnum | |||
| ) | [static] |
Binary write function, with byte swapping if needed.
| fp | [in] file pointer | |
| buf | [in] data buffer to write | |
| unitbyte | [in] unit size in bytes | |
| unitnum | [in] number of unit to write |
ngram_write_bin.c の 82 行で定義されています。
| static boolean write_header | ( | FILE * | fp, | |
| char * | str | |||
| ) | [static] |
Write header information, with identifier string.
| fp | [in] file pointer | |
| str | [in] user header string (any string within BINGRAM_HDSIZE bytes is allowed) | |
| version | [in] file format version id |
ngram_write_bin.c の 107 行で定義されています。
参照元 ngram_write_bin().
| boolean ngram_write_bin | ( | FILE * | fp, | |
| NGRAM_INFO * | ndata, | |||
| char * | headerstr | |||
| ) |
Write a whole N-gram data in binary format.
| fp | [in] file pointer | |
| ndata | [in] N-gram data to write | |
| headerstr | [in] user header string |
ngram_write_bin.c の 135 行で定義されています。
1.5.1