libsent/src/ngram/ngram_write_bin.c File Reference

Write a whole N-gram data to a file in binary format. More...

#include <sent/stddefs.h>
#include <sent/ngram2.h>

Include dependency graph for ngram_write_bin.c:

Go to the source code of this file.

Functions

static void wrt (FILE *fp, void *buf, size_t unitbyte, int unitnum)
static void write_header (FILE *fp, char *str, int version)
boolean ngram_write_bin (FILE *fp, NGRAM_INFO *ndata, char *headerstr)

Variables

static boolean need_swap
 TRUE if need byte swap.


Detailed Description

Write a whole N-gram data to a file in binary format.

Author:
Akinobu LEE
Date:
Wed Feb 16 17:23:16 2005
From 3.5, internal format of binary N-gram has changed for using machine-dependent natural byte order (previously fixed to big endian), 24bit index and 2-gram backoff compression. So, binary N-gram generated by mkbingram of 3.5 and later will not work on 3.4.2 and earlier versions.

There is full upward- and cross-machine compatibility in 3.5. Old binary N-gram files still can be read directly, in which case the conversion to 24bit index will performed just after model has been read. Byte order will also considered by header information, so binary N-gram still can be used among different machines.

Revision
1.4

Definition in file ngram_write_bin.c.


Function Documentation

static void wrt ( FILE *  fp,
void *  buf,
size_t  unitbyte,
int  unitnum 
) [static]

Binary write function, with byte swapping if needed.

Parameters:
fp [in] file pointer
buf [in] data buffer to write
unitbyte [in] unit size in bytes
unitnum [in] number of unit to write

Definition at line 66 of file ngram_write_bin.c.

static void write_header ( FILE *  fp,
char *  str,
int  version 
) [static]

Write header information, with identifier string.

Parameters:
fp [in] file pointer
str [in] user header string (any string within BINGRAM_HDSIZE bytes is allowed)
version [in] file format version id

Definition at line 89 of file ngram_write_bin.c.

Referenced by ngram_write_bin().

boolean ngram_write_bin ( FILE *  fp,
NGRAM_INFO ndata,
char *  headerstr 
)

Write a whole N-gram data in binary format.

Parameters:
fp [in] file pointer
ndata [in] N-gram data to write
headerstr [in] user header string
Returns:
TRUE on success, FALSE on failure

Definition at line 128 of file ngram_write_bin.c.


Generated on Tue Dec 26 16:18:08 2006 for Julius by  doxygen 1.5.0