libak
0.4.0
|
Defines | |
#define | ak_priors_free(PRIORS) (free ( PRIORS )) |
Frees memory. | |
Typedefs | |
typedef akProb | akPriors |
Table of Prior probabilities. | |
Functions | |
akPriors * | ak_priors_new (const size_t N) |
Creates a table of prior probabilities. | |
void | ak_priors_print (const akPriors *priors, FILE *to, const akDict *words, const akBool binary) |
Prints the table of priors probabilities. | |
akPriors * | ak_priors_new_from_file (FILE *from, akLexicon *lexicon, const akBool emptylex, akDict *syms, char **err) |
Reads a table of prior probabilities. | |
void | ak_priors_set_gsf (akPriors *priors, const size_t N, const akFloat gsf) |
Sets the grammar scale factor. |
#define ak_priors_free | ( | PRIORS | ) | (free ( PRIORS )) |
Frees memory.
Frees the memory allocated for the table of prior probabilities.
PRIORS | The table of priors probabilities. |
Table of Prior probabilities.
This structure stores a table of log-probabilities, one entry for each prior probability.
akPriors* ak_priors_new | ( | const size_t | N | ) |
Creates a table of prior probabilities.
This functions creates a new table of prior probabilities of the given size, initialised to 0.
N | Size of the new table. |
akPriors* ak_priors_new_from_file | ( | FILE * | from, |
akLexicon * | lexicon, | ||
const akBool | emptylex, | ||
akDict * | syms, | ||
char ** | err | ||
) |
Reads a table of prior probabilities.
This functions creates a new table of prior probabilities from a text description stored in the given file. A akLexicon is provided to register the words or class labels. If the lexicon is empty new labels are registered into the lexicon, else a label out of vocabulary is treated as an error. If a akDict is provided new registered labels are considered to be coded in UTF-8 and split into characters, being an out of dictionary character an error. In other case, new labels are registered whit an empty sequence of symbols. Hence, in this case the resulting akLexicon is a bad formed akLexicon, however, it can be used to print the table of prior probabilities.
from | File where the text description is stored. |
lexicon | The lexicon where labels are registered. |
emptylex | Indicates if the provided lexicon is empty (new labels must be registered) or not (new labels are treated as errors). |
syms | A character dictionary used to register new labels. If not NULL out of vocabulary characters are treated as errors, if NULL characters are ignored. |
err | Pointer to string variable. If not NULL an error message is allocated in the variable in case of error. |
void ak_priors_print | ( | const akPriors * | priors, |
FILE * | to, | ||
const akDict * | words, | ||
const akBool | binary | ||
) |
Prints the table of priors probabilities.
This functions writes in the given file the content of the table of priors probabilities in text format. Each component is linked to a word or class label, which is obtained from the provided akDict. The size of the table is the number of words in the given akDict. The binary format is not a compact nor portable representation, but a way to ensure that parameters are written as they are stored in memory.
priors | The table of prior probabilities. |
to | File where the table is written. |
words | A dictionary with the words or class labels. The number of words must be equal to the size of the table. |
binary | If false the priors are written in text format, else in binary format. |
void ak_priors_set_gsf | ( | akPriors * | priors, |
const size_t | N, | ||
const akFloat | gsf | ||
) |
Sets the grammar scale factor.
This function modifies the given table of prior probabilities by applying the given grammar scale factor. Note that if a previous grammar scale factor (gsf0) was applied, the resulting table will have a grammar scale factor of gsf0*gsf.
priors | The table of prior probabilities. |
N | The size of the table. |
gsf | Grammar scale factor. |