libak  0.4.0
Defines | Typedefs | Functions
Prior probabilities
Models

Defines

#define ak_priors_free(PRIORS)   (free ( PRIORS ))
 Frees memory.

Typedefs

typedef akProb akPriors
 Table of Prior probabilities.

Functions

akPriorsak_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.
akPriorsak_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 Documentation

#define ak_priors_free (   PRIORS)    (free ( PRIORS ))

Frees memory.

Frees the memory allocated for the table of prior probabilities.

Parameters:
PRIORSThe table of priors probabilities.

Typedef Documentation

typedef akProb akPriors

Table of Prior probabilities.

This structure stores a table of log-probabilities, one entry for each prior probability.


Function Documentation

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.

Parameters:
NSize of the new table.
Returns:
The new prior probabilities 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.

Parameters:
fromFile where the text description is stored.
lexiconThe lexicon where labels are registered.
emptylexIndicates if the provided lexicon is empty (new labels must be registered) or not (new labels are treated as errors).
symsA character dictionary used to register new labels. If not NULL out of vocabulary characters are treated as errors, if NULL characters are ignored.
errPointer to string variable. If not NULL an error message is allocated in the variable in case of error.
Returns:
The table of prior probabilities, or NULL 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.

Parameters:
priorsThe table of prior probabilities.
toFile where the table is written.
wordsA dictionary with the words or class labels. The number of words must be equal to the size of the table.
binaryIf 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.

Parameters:
priorsThe table of prior probabilities.
NThe size of the table.
gsfGrammar scale factor.
 All Data Structures Variables