#include <sent/stddefs.h>
#include <sent/ngram2.h>
マクロ定義 | |
#define | rdn(A, B, C, D) if (rdnfunc(A,B,C,D) == FALSE) return FALSE |
#define | rdn_wordid(A, B, C, D) if (rdn_wordid_func(A,B,C,D) == FALSE) return FALSE |
関数 | |
static boolean | rdnfunc (FILE *fp, void *buf, size_t unitbyte, int unitnum) |
Binary read function with byte swap | |
static boolean | check_header (FILE *fp) |
Check header to see whether the version matches. | |
static boolean | ngram_read_bin_v5 (FILE *fp, NGRAM_INFO *ndata) |
static boolean | ngram_read_bin_compat (FILE *fp, NGRAM_INFO *ndata, int *retry_ret) |
boolean | ngram_read_bin (FILE *fp, NGRAM_INFO *ndata) |
Read a N-gram binary file and store to data. | |
変数 | |
static int | file_version |
N-gram format version of the file | |
static boolean | need_swap |
TRUE if need byte swap |
バイナリ形式では 2-gram と逆向き 3-gram が1つのファイルに 収められています.バイナリ形式はJuilus独自形式のみをサポートしており, 他のバイナリ形式と互換性はありませんので注意して下さい.
rev.3.5 より,バイナリN-gramのファイル形式の一部が変更されました. バイトオーダーが Big endian 固定からマシン依存に変更され(ヘッダに 変換時の条件を記述), またインデックスの 24bit 化 および 2-gram のバックオフデータの圧縮も行われました. これにより,3.5 以降の mkbingram で生成したバイナリN-gramは, 3.4.2以前の Julius では使えませんので注意してください. (ヘッダチェックでエラーとなる)
なお 3.5 以降の Julius では従来のモデルも問題なく読める.この場合, インデックスの 24bit 化とバックオフの圧縮はモデル読み込み時に その都度行われる.またバイトオーダーはヘッダを見て適宜変換するので, 異なるバイトオーダーのマシンで生成した バイナリN-gramでも問題なく読める.もちろん従来のモデルもそのまま 読み込める.
ngram_read_bin.c で定義されています。
static boolean rdnfunc | ( | FILE * | fp, | |
void * | buf, | |||
size_t | unitbyte, | |||
int | unitnum | |||
) | [static] |
Binary read function with byte swap
fp | [in] file pointer | |
buf | [out] data buffer | |
unitbyte | [in] unit size in bytes | |
unitnum | [in] number of unit to read. |
ngram_read_bin.c の 86 行で定義されています。
static boolean check_header | ( | FILE * | fp | ) | [static] |
Check header to see whether the version matches.
fp | [in] file pointer |
ngram_read_bin.c の 141 行で定義されています。
参照元 ngram_read_bin().
boolean ngram_read_bin | ( | FILE * | fp, | |
NGRAM_INFO * | ndata | |||
) |
Read a N-gram binary file and store to data.
fp | [in] file pointer | |
ndata | [out] N-gram data to store the read data |
ngram_read_bin.c の 604 行で定義されています。
参照元 init_ngram_bin().