libsent/src/ngram/ngram_access.c File Reference

Get N-gram probability of a word/class sequence. More...

#include <sent/stddefs.h>
#include <sent/ngram2.h>

Go to the source code of this file.

Functions

static NNID search_ngram_core (NGRAM_INFO *ndata, int n, int nid_prev, WORD_ID wkey)
 Search for n-gram tuple.
NNID search_ngram (NGRAM_INFO *ndata, int n, WORD_ID *w)
 Search for N-tuples.
LOGPROB ngram_prob (NGRAM_INFO *ndata, int n, WORD_ID *w)
 Get N-gram probability of the last word w_n, given context w_1^n-1.
LOGPROB uni_prob (NGRAM_INFO *ndata, WORD_ID w)
 Get 1-gram probability of $w$ in log10.
static NNID search_bigram (NGRAM_INFO *ndata, WORD_ID w_context, WORD_ID w)
 Find bi-gram entry.
static LOGPROB bi_prob_normal (NGRAM_INFO *ndata, WORD_ID w1, WORD_ID w2)
 Get LR bi-gram prob: for LR N-gram.
static LOGPROB bi_prob_additional_oldbin (NGRAM_INFO *ndata, WORD_ID w1, WORD_ID w2)
 Get LR bi-gram prob: for RL N-gram with additional LR 2-gram, in old bingram format.
static LOGPROB bi_prob_additional (NGRAM_INFO *ndata, WORD_ID w1, WORD_ID w2)
 Get LR bi-gram prob: for RL N-gram with additional LR 2-gram.
static LOGPROB bi_prob_compute (NGRAM_INFO *ndata, WORD_ID w1, WORD_ID w2)
 Get LR bi-gram prob: for RL N-gram with no LR 2-gram.
LOGPROB bi_prob (NGRAM_INFO *ndata, WORD_ID w1, WORD_ID w2)
 Get 2-gram probability This function is not used in Julius, since each function of bi_prob_* will be called directly from the search.
void bi_prob_func_set (NGRAM_INFO *ndata)
 Determinte which bi-gram computation function to be used according to the N-gram type, and set pointer to the proper function into the N-gram data.


Detailed Description

Get N-gram probability of a word/class sequence.

Author:
Akinobu LEE
Date:
Wed Feb 16 07:46:18 2005
Revision
1.1.1.1

Definition in file ngram_access.c.


Function Documentation

static NNID search_ngram_core ( NGRAM_INFO ndata,
int  n,
int  nid_prev,
WORD_ID  wkey 
) [static]

Search for n-gram tuple.

Parameters:
ndata [in] word/class N-gram
n [in] N of N-gram
nid_prev [in] context (N-1)-gram tuple ID
wkey [in] the target word ID
Returns:
corresponding index to the 2-gram data part if found, or NNID_INVALID if the tuple does not exist in 2-gram.

Definition at line 43 of file ngram_access.c.

Referenced by ngram_prob(), and search_ngram().

NNID search_ngram ( NGRAM_INFO ndata,
int  n,
WORD_ID w 
)

Search for N-tuples.

Parameters:
ndata [in] word/class N-gram
n [in] N of N-gram (= number of words in w)
w [in] word sequence
Returns:

Definition at line 103 of file ngram_access.c.

Referenced by add_bigram(), and set_ngram().

LOGPROB ngram_prob ( NGRAM_INFO ndata,
int  n,
WORD_ID w 
)

Get N-gram probability of the last word w_n, given context w_1^n-1.

Parameters:
ndata [in] word/class N-gram
n [in] N of N-gram (= number of words in w)
w [in] word sequence
Returns:

Definition at line 135 of file ngram_access.c.

Referenced by ngram_forw2back(), ngram_prob(), and pick_backtrellis_words().

LOGPROB uni_prob ( NGRAM_INFO ndata,
WORD_ID  w 
)

Get 1-gram probability of $w$ in log10.

Parameters:
ndata [in] word/class N-gram
w [in] word/class ID in N-gram
Returns:
log10 probability $\log p(w)$.

Definition at line 229 of file ngram_access.c.

static NNID search_bigram ( NGRAM_INFO ndata,
WORD_ID  w_context,
WORD_ID  w 
) [static]

Find bi-gram entry.

Assumes ct_compaction and is24bit is FALSE on 2-gram

Parameters:
ndata [in] N-gram data that holds the 2-gram
w_context [in] context word ID
w [in] target word ID
Returns:
the ID of N-gram tuple entry ID where the (w_context, w) exists.

Definition at line 249 of file ngram_access.c.

Referenced by bi_prob_additional(), bi_prob_additional_oldbin(), bi_prob_compute(), and bi_prob_normal().

static LOGPROB bi_prob_normal ( NGRAM_INFO ndata,
WORD_ID  w1,
WORD_ID  w2 
) [static]

Get LR bi-gram prob: for LR N-gram.

Parameters:
ndata [in] N-gram data that holds the 2-gram
w1 [in] left context word
w2 [in] right target word
Returns:
the log N-gram probability P(w2|w1)

Definition at line 288 of file ngram_access.c.

Referenced by bi_prob(), and bi_prob_func_set().

static LOGPROB bi_prob_additional_oldbin ( NGRAM_INFO ndata,
WORD_ID  w1,
WORD_ID  w2 
) [static]

Get LR bi-gram prob: for RL N-gram with additional LR 2-gram, in old bingram format.

The old format has 2-gram index in reversed orfer, so this function is for old bingram formats.

Parameters:
ndata [in] N-gram data that holds the 2-gram
w1 [in] left context word
w2 [in] right target word
Returns:
the log N-gram probability P(w2|w1)

Definition at line 320 of file ngram_access.c.

Referenced by bi_prob(), and bi_prob_func_set().

static LOGPROB bi_prob_additional ( NGRAM_INFO ndata,
WORD_ID  w1,
WORD_ID  w2 
) [static]

Get LR bi-gram prob: for RL N-gram with additional LR 2-gram.

Parameters:
ndata [in] N-gram data that holds the 2-gram
w1 [in] left context word
w2 [in] right target word
Returns:
the log N-gram probability P(w2|w1)

Definition at line 351 of file ngram_access.c.

Referenced by bi_prob(), and bi_prob_func_set().

static LOGPROB bi_prob_compute ( NGRAM_INFO ndata,
WORD_ID  w1,
WORD_ID  w2 
) [static]

Get LR bi-gram prob: for RL N-gram with no LR 2-gram.

This function will compute the LR 2-gram from the RL 2-gram.

Parameters:
ndata [in] N-gram data that holds the 2-gram
w1 [in] left context word
w2 [in] right target word
Returns:
the log N-gram probability P(w2|w1)

Definition at line 383 of file ngram_access.c.

Referenced by bi_prob(), and bi_prob_func_set().

LOGPROB bi_prob ( NGRAM_INFO ndata,
WORD_ID  w1,
WORD_ID  w2 
)

Get 2-gram probability This function is not used in Julius, since each function of bi_prob_* will be called directly from the search.

Parameters:
ndata [in] N-gram data that holds the 2-gram
w1 [in] left context word
w2 [in] right target word
Returns:
the log N-gram probability P(w2|w1)

Definition at line 419 of file ngram_access.c.

void bi_prob_func_set ( NGRAM_INFO ndata  ) 

Determinte which bi-gram computation function to be used according to the N-gram type, and set pointer to the proper function into the N-gram data.

Parameters:
ndata [i/o] N-gram information to use

Definition at line 449 of file ngram_access.c.

Referenced by ngram_read_arpa(), and ngram_read_bin().


Generated on Tue Dec 18 16:01:40 2007 for Julius by  doxygen 1.5.4