#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include "segCommon.h"
#include "segStdLib.h"
Defines | |
#define | MAX_STR_LEN 1024 |
Maximum possible number of characters for a string. | |
Functions | |
double | logProb (double prob) |
Logarithmic operation for probability calculation. | |
double ** | allocDblMatrix (int nrow, int ncol) |
Allocate memory for an (nrow x ncol) matrix. | |
void | freeDblMatrix (double **mat, int nrow) |
Free memory space of a matrix. | |
int ** | allocIntMatrix (int nrow, int ncol) |
Allocate memory for an (nrow x ncol) matrix. | |
void | freeIntMatrix (int **mat, int nrow) |
Free memory space of a matrix. | |
short ** | allocShtMatrix (int nrow, int ncol) |
Allocate memory for an (nrow x ncol) matrix. | |
void | freeShtMatrix (short **mat, int nrow) |
Free memory space of a matrix. | |
long ** | allocLngMatrix (int nrow, int ncol) |
Allocate memory for an (nrow x ncol) matrix. | |
void | freeLngMatrix (long **mat, int nrow) |
Free memory space of a matrix. | |
int | countLines (FILE *ip) |
Count the number of lines in a text file. | |
int | probeWord (char *word, int size, FILE *fp) |
Read a word from a given file pointer without incrementing the pointer. | |
char * | allocCopyStr (char *source) |
Allocate memory space and copy a string to the space. | |
char * | extractLastDiphone (char *label) |
Extract the last diphone from a given triphone. | |
char * | extractFirstDiphone (char *label) |
Extract the first diphone included in the triphone. | |
char * | extractCentrePhone (char *label) |
Extract the centre phone of the triphone. |
char* allocCopyStr | ( | char * | source | ) |
Allocate memory space and copy a string to the space.
[in] | source |
NULL | Memory allocation error | |
otherwise | Pointer to the string copied |
double** allocDblMatrix | ( | int | nrow, | |
int | ncol | |||
) |
Allocate memory for an (nrow x ncol) matrix.
[in] | nrow | Number of rows |
[in] | ncol | Number of columns |
NULL | Memory allocation error | |
otherwise | Pointer to the matrix allocated |
int** allocIntMatrix | ( | int | nrow, | |
int | ncol | |||
) |
Allocate memory for an (nrow x ncol) matrix.
[in] | nrow | Number of rows |
[in] | ncol | Number of columns |
NULL | Memory allocation error | |
otherwise | Pointer to the matrix allocated |
long** allocLngMatrix | ( | int | nrow, | |
int | ncol | |||
) |
Allocate memory for an (nrow x ncol) matrix.
[in] | nrow | Number of rows |
[in] | ncol | Number of columns |
NULL | Memory allocation error | |
otherwise | Pointer to the matrix allocated |
short** allocShtMatrix | ( | int | nrow, | |
int | ncol | |||
) |
Allocate memory for an (nrow x ncol) matrix.
[in] | nrow | Number of rows |
[in] | ncol | Number of columns |
NULL | Memory allocation error | |
otherwise | Pointer to the matrix allocated |
int countLines | ( | FILE * | ip | ) |
Count the number of lines in a text file.
[in] | ip | File pointer to the file |
char* extractCentrePhone | ( | char * | label | ) |
Extract the centre phone of the triphone.
[in] | label | Triphone label |
char* extractFirstDiphone | ( | char * | label | ) |
Extract the first diphone included in the triphone.
[in] | label | Triphone label |
char* extractLastDiphone | ( | char * | label | ) |
Extract the last diphone from a given triphone.
[in] | label | Triphone label |
void freeDblMatrix | ( | double ** | mat, | |
int | nrow | |||
) |
Free memory space of a matrix.
[in] | mat | Pointer to the matrix |
[in] | nrow | Number of rows |
void freeIntMatrix | ( | int ** | mat, | |
int | nrow | |||
) |
Free memory space of a matrix.
[in] | mat | Pointer to the matrix |
[in] | nrow | Number of rows |
void freeLngMatrix | ( | long ** | mat, | |
int | nrow | |||
) |
Free memory space of a matrix.
[in] | mat | Pointer to the matrix |
[in] | nrow | Number of rows |
void freeShtMatrix | ( | short ** | mat, | |
int | nrow | |||
) |
Free memory space of a matrix.
[in] | mat | Pointer to the matrix |
[in] | nrow | Number of rows |
double logProb | ( | double | prob | ) |
Logarithmic operation for probability calculation.
[in] | prob | Probability |
int probeWord | ( | char * | word, | |
int | size, | |||
FILE * | fp | |||
) |
Read a word from a given file pointer without incrementing the pointer.
[in,out] | word | Pointer to an array to which a read word is stored |
[in] | size | Maximum possible length of the word in byte |
[in] | fp | File pointer from which the word is read |
ERROR_FREAD | File read error | |
ERROR_ALLOC | Memory allocation error | |
RTN_ERROR | Error: bad file format | |
NO_ERROR | Successful execution |