Main Page   Compound List   File List   Compound Members   File Members  

rr_libs/sih.h File Reference

Declaration of string-to-int32 hash. More...

#include <sys/types.h>
#include <stdio.h>
#include "general.h"

Go to the source code of this file.

Compounds

struct  sih_slot_t
 one slot of string to integer table More...

struct  sih_t
 string to integer table More...


Functions

sih_tsih_create (int initial_size, double max_occupancy, double growth_ratio, int warn_on_update)
void sih_add (sih_t *ht, char *string, int32 intval)
char sih_lookup (sih_t *ht, char *string, int32 *p_intval)
void * sih_val_write_to_file (sih_t *ht, FILE *fp, char *filename, int verbosity)
void * sih_val_read_from_file (sih_t *ht, FILE *fp, char *filename, int verbosity)
void get_vocab_from_vocab_ht (sih_t *ht, int vocab_size, int verbosity, char ***p_vocab)
void read_wlist_into_siht (char *wlist_filename, int verbosity, sih_t *p_word_id_ht, int *p_n_wlist)
void read_wlist_into_array (char *wlist_filename, int verbosity, char ***p_wlist, int *p_n_wlist)


Detailed Description

Declaration of string-to-int32 hash.

Definition in file sih.h.


Function Documentation

void get_vocab_from_vocab_ht sih_t   ht,
int    vocab_size,
int    verbosity,
char ***    p_vocab
 

derive the vocab from the vocab hash table

Definition at line 74 of file read_voc.c.

References fprintf(), sih_slot_t::intval, sih_t::nslots, quit(), rr_malloc(), sih_t::slots, sih_slot_t::string, and verbosity.

Referenced by load_lm(), and read_voc().

void read_wlist_into_array char *    wlist_filename,
int    verbosity,
char ***    p_wlist,
int *    p_n_wlist
 

Referenced by read_voc().

void read_wlist_into_siht char *    wlist_filename,
int    verbosity,
sih_t   p_word_id_ht,
int *    p_n_wlist
 

read_wlist_into_siht: read a word list into a string-to-int32 hash table

Parameters:
wlist_filename  Input word list filename
verbosity  verbosity of this function
p_word_id_ht  Output: output string-to-int32 hash
p_n_wlist  Output: the number of words in the word list

Definition at line 28 of file read_wlist_si.c.

References fprintf(), p_n_wlist, rr_iclose(), rr_iopen(), salloc(), sih_add(), and verbosity.

Referenced by read_voc().

void sih_add sih_t   ht,
char *    string,
int32    intval
 

Add an entry to hash

Parameters:
ht  The hash table
string  Input: The string
intval  Output: The integer value

Definition at line 91 of file sih.c.

References fprintf(), free(), sih_t::growth_ratio, int32, sih_slot_t::intval, intval, sih_t::max_occupancy, nearest_prime_up(), sih_t::nentries, sih_t::nslots, quit(), rr_calloc(), SIH_KEY, sih_t::slots, sih_slot_t::string, and sih_t::warn_on_update.

Referenced by load_arpa_lm(), and read_wlist_into_siht().

sih_t* sih_create int    initial_size,
double    max_occupancy,
double    growth_ratio,
int    warn_on_update
 

Create a string to integer hash

Parameters:
initial_size  Initial size of the hash
warn_on_update  Whether warning is given in an update

Definition at line 69 of file sih.c.

References sih_t::growth_ratio, MAX, sih_t::max_occupancy, nearest_prime_up(), sih_t::nentries, sih_t::nslots, quit(), rr_calloc(), rr_malloc(), sih_t::slots, and sih_t::warn_on_update.

Referenced by load_arpa_lm(), and main().

char sih_lookup sih_t   ht,
char *    string,
int32   p_intval
 

Lookup the hash table

Parameters:
ht  The hash table
string  Input: the string
p_intval  Output: the pointer of an integer value

Definition at line 145 of file sih.c.

References int32, sih_slot_t::intval, sih_t::nslots, quit(), SIH_KEY, sih_t::slots, and sih_slot_t::string.

Referenced by compute_perplexity(), gen_fb_list(), load_arpa_lm(), main(), and validate().

void* sih_val_read_from_file sih_t   ht,
FILE *    fp,
char *    filename,
int    verbosity
 

Read the value from a file to a hash

Parameters:
ht  The hash table
fp  the file handle of the input
filename  the file name of the output
verbosity  verbosity of the this function

Definition at line 227 of file sih.c.

References fprintf(), sih_t::growth_ratio, HASH_VERSION, int32, sih_slot_t::intval, sih_t::max_occupancy, sih_t::nentries, sih_t::nslots, quit(), rr_calloc(), rr_fread(), rr_malloc(), sih_t::slots, sih_slot_t::string, verbosity, and sih_t::warn_on_update.

Referenced by load_lm(), and read_voc().

void* sih_val_write_to_file sih_t   ht,
FILE *    fp,
char *    filename,
int    verbosity
 

Read/Write from/to a file an (almost) ready-to-use hash table. The hash-table is a string->int mapping. All intvals are written out, whether or not they belong to active entries. All strings are writen out too, where an empty entry is represented in the file as a null string (null strings as entries are not allowed).

Parameters:
ht  The hash table
fp  the file handle of the output
filename  the file name of the output
verbosity  verbosity of the this function

Definition at line 181 of file sih.c.

References fprintf(), sih_t::growth_ratio, HASH_VERSION, int32, sih_slot_t::intval, sih_t::max_occupancy, sih_t::nentries, sih_t::nslots, quit(), rr_fwrite(), sih_t::slots, sih_slot_t::string, verbosity, and sih_t::warn_on_update.

Referenced by write_bin_lm().


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