Main Page   Compound List   File List   Compound Members   File Members  

rr_libs/general.h File Reference

Declaration of customized version of file IO utilities. More...

#include <stdio.h>
#include <sys/types.h>
#include <math.h>
#include <string.h>

Go to the source code of this file.

Defines

#define CMU_SLM_VERSION   "CMU SLM Toolkit, Version for internal CMU use"
#define MIN(X, Y)   ( ((X)<(Y)) ? (X) : (Y))
#define MAX(X, Y)   ( ((X)>(Y)) ? (X) : (Y))
#define LOG_BASE   9.9995e-5
#define MIN_LOG   -690810000
#define LOG(x)
#define EXP(x)   (exp ((double) (x) * LOG_BASE))
#define quit0(rc, msg)   {fprintf(stderr,msg); exit(rc);}
#define quit1(rc, msg, i1)   {fprintf(stderr,msg,i1); exit(rc);}
#define quit2(rc, msg, i1, i2)   {fprintf(stderr,msg,i1,i2); exit(rc);}
#define quit3(rc, msg, i1, i2, i3)   {fprintf(stderr,msg,i1,i2,i3); exit(rc);}
#define quit4(rc, msg, i1, i2, i3, i4)   {fprintf(stderr,msg,i1,i2,i3,i4); exit(rc);}
#define MAX_WORDS_PER_DOC   65534

Typedefs

typedef int int32
typedef short int16
typedef char Boolean
typedef unsigned short wordid_t
typedef int cluster_t

Functions

FILE * rr_fopen (char *filename, char *mode)
void * rr_fseek (FILE *fp, int offset, int mode, char *description)
void * rr_fread ()
void * rr_fwrite ()
char * rr_malloc (size_t n_bytes)
char * rr_calloc (size_t nelem, size_t elsize)
int rr_filesize (int fd)
int rr_feof (FILE *fp)
char * salloc (char *str)
int rr_fexists (char *path)
FILE * rr_iopen (char *path)
void * rr_iclose (FILE *fp)
FILE * rr_oopen (char *path)
void * rr_oclose (FILE *fp)
void parse_line (char *line, int mwords, int canonize, char **pword_begin, char **pword_end, int *p_nwords, int *p_overflow)
int quit (int rc, char *msg,...)


Detailed Description

Declaration of customized version of file IO utilities.

Definition in file general.h.


Define Documentation

#define CMU_SLM_VERSION   "CMU SLM Toolkit, Version for internal CMU use"
 

Definition at line 26 of file general.h.

#define EXP      (exp ((double) (x) * LOG_BASE))
 

Definition at line 89 of file general.h.

#define LOG  
 

Value:

((x == 0.0) ? MIN_LOG : ((x > 1.0) ?                        \
                                        (int) ((log (x) / LOG_BASE) + 0.5) :\
                                        (int) ((log (x) / LOG_BASE) - 0.5)))

Definition at line 86 of file general.h.

#define LOG_BASE   9.9995e-5
 

Definition at line 84 of file general.h.

#define MAX X,
     ( ((X)>(Y)) ? (X) : (Y))
 

Definition at line 81 of file general.h.

Referenced by main(), merge_tempfiles(), rr_calloc(), rr_malloc(), and sih_create().

#define MAX_WORDS_PER_DOC   65534
 

Definition at line 103 of file general.h.

#define MIN X,
     ( ((X)<(Y)) ? (X) : (Y))
 

Definition at line 78 of file general.h.

Referenced by compute_gt_discount().

#define MIN_LOG   -690810000
 

Definition at line 85 of file general.h.

#define quit0 rc,
msg       {fprintf(stderr,msg); exit(rc);}
 

Definition at line 97 of file general.h.

#define quit1 rc,
msg,
i1       {fprintf(stderr,msg,i1); exit(rc);}
 

Definition at line 98 of file general.h.

#define quit2 rc,
msg,
i1,
i2       {fprintf(stderr,msg,i1,i2); exit(rc);}
 

Definition at line 99 of file general.h.

#define quit3 rc,
msg,
i1,
i2,
i3       {fprintf(stderr,msg,i1,i2,i3); exit(rc);}
 

Definition at line 100 of file general.h.

#define quit4 rc,
msg,
i1,
i2,
i3,
i4       {fprintf(stderr,msg,i1,i2,i3,i4); exit(rc);}
 

Definition at line 101 of file general.h.


Typedef Documentation

typedef char Boolean
 

Definition at line 73 of file general.h.

Referenced by main().

typedef int cluster_t
 

Definition at line 75 of file general.h.

typedef short int16
 

Definition at line 34 of file general.h.

typedef int int32
 

the following should be made machine-dependent

Definition at line 33 of file general.h.

Referenced by sih_add(), sih_lookup(), sih_val_read_from_file(), and sih_val_write_to_file().

typedef unsigned short wordid_t
 

Definition at line 74 of file general.h.


Function Documentation

void parse_line char *    line,
int    mwords,
int    canonize,
char **    pword_begin,
char **    pword_end,
int *    p_nwords,
int *    p_overflow
 

Definition at line 24 of file parse_line.c.

int quit int    rc,
char *    msg,
...   
 

Definition at line 26 of file quit.c.

Referenced by calc_prob_of(), cmp_ngram(), compute_perplexity(), compute_unigram(), double_alpha(), get_ngram(), get_vocab_from_vocab_ht(), get_word(), load_arpa_lm(), load_lm(), main(), merge_tempfiles(), pc_intarrayarg(), pc_report_unk_args(), pc_shortarrayarg(), report_version(), rr_calloc(), rr_feof(), rr_fopen(), rr_fread(), rr_fseek(), rr_fwrite(), rr_iopen(), rr_malloc(), rr_oopen(), short_alpha(), sih_add(), sih_create(), sih_lookup(), sih_val_read_from_file(), sih_val_write_to_file(), validate(), and write_ngram().

char* rr_calloc size_t    nelem,
size_t    elsize
 

customized version of calloc

Definition at line 32 of file rr_calloc.c.

References MAX, and quit().

Referenced by calc_mem_req(), compute_back_off(), compute_gt_discount(), compute_perplexity(), gen_fb_list(), increment_context(), load_arpa_lm(), load_lm(), main(), merge_tempfiles(), sih_add(), sih_create(), and sih_val_read_from_file().

int rr_feof FILE *    fp
 

customized version of feof

Definition at line 29 of file rr_feof.c.

References quit().

Referenced by calc_mem_req(), compute_perplexity(), get_ngram(), load_arpa_lm(), main(), and merge_tempfiles().

int rr_fexists char *    path
 

check whether a file exists

Definition at line 24 of file rr_fexists.c.

Referenced by compute_perplexity(), and rr_iopen().

int rr_filesize int    fd
 

get the file size of a file handle

Definition at line 24 of file rr_filesize.c.

FILE* rr_fopen char *    filename,
char *    mode
 

customized version of fopen

Definition at line 25 of file rr_fopen.c.

References quit().

Referenced by main(), rr_iopen(), and rr_oopen().

void* rr_fread  
 

customized version of fread

Referenced by get_ngram(), load_lm(), main(), merge_tempfiles(), and sih_val_read_from_file().

void* rr_fseek FILE *    fp,
int    offset,
int    mode,
char *    description
 

customized version of fseek

Definition at line 30 of file rr_fseek.c.

References quit().

void* rr_fwrite  
 

customized version of fwrite

Referenced by main(), merge_tempfiles(), sih_val_write_to_file(), write_bin_lm(), and write_ngram().

void* rr_iclose FILE *    fp
 

Definition at line 103 of file rr_iopen.c.

References RRi_is_Z.

Referenced by calc_mem_req(), compute_perplexity(), gen_fb_list(), load_arpa_lm(), load_lm(), main(), merge_tempfiles(), read_voc(), and read_wlist_into_siht().

FILE* rr_iopen char *    path
 

Definition at line 44 of file rr_iopen.c.

References quit(), rr_fexists(), rr_fopen(), and RRi_is_Z.

Referenced by calc_mem_req(), compute_perplexity(), gen_fb_list(), load_arpa_lm(), load_lm(), main(), merge_tempfiles(), read_voc(), and read_wlist_into_siht().

char* rr_malloc size_t    n_bytes
 

customized version of malloc

Definition at line 31 of file rr_malloc.c.

References MAX, and quit().

Referenced by arpa_bo_ng_prob(), bo_ng_prob(), calc_mem_req(), calc_prob_of(), compute_perplexity(), get_vocab_from_vocab_ht(), guess_mem(), load_arpa_lm(), load_lm(), main(), merge_tempfiles(), new_node(), pc_intarrayarg(), pc_shortarrayarg(), salloc(), sih_create(), sih_val_read_from_file(), and validate().

void* rr_oclose FILE *    fp
 

Definition at line 82 of file rr_oopen.c.

FILE* rr_oopen char *    path
 

open a file, it can also handle .Z and .gz extension

Definition at line 43 of file rr_oopen.c.

References quit(), rr_fopen(), and RRo_is_Z.

Referenced by compute_perplexity(), main(), and merge_tempfiles().

char* salloc char *    str
 

customized version of salloc

Definition at line 25 of file salloc.c.

References rr_malloc().

Referenced by load_arpa_lm(), load_lm(), main(), merge_tempfiles(), parse_comline(), read_voc(), and read_wlist_into_siht().


Generated on Tue Dec 21 13:54:47 2004 by doxygen1.2.18