Julius 4.2
マクロ定義 | 関数 | 変数
libsent/src/ngram/ngram_read_bin.c

バイナリ形式のN-gramファイルを読み込む [詳細]

#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, size_t 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.

説明

バイナリ形式のN-gramファイルを読み込む

バイナリ形式では 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でも問題なく読める.もちろん従来のモデルもそのまま 読み込める.

作者:
Akinobu LEE
日付:
Wed Feb 16 17:12:08 2005
Revision:
1.8

ngram_read_bin.c で定義されています。


関数

static boolean rdnfunc ( FILE *  fp,
void *  buf,
size_t  unitbyte,
size_t  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.c86 行で定義されています。

static boolean check_header ( FILE *  fp) [static]

Check header to see whether the version matches.

引数:
fp[in] file pointer

ngram_read_bin.c142 行で定義されています。

参照元 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
戻り値:
TRUE on success, FALSE on failure.

ngram_read_bin.c594 行で定義されています。

参照元 init_ngram_bin().