Grammar / Dictionary API
[JuliusLib API]

Collaboration diagram for Grammar / Dictionary API:

Functions to manage grammars or word dictionaries at run time. More...

Functions

void multigram_add_gramlist (char *dfafile, char *dictfile, JCONF_LM *j, int lmvar)
 Add a grammar to the grammar list to be read at startup.
void multigram_remove_gramlist (JCONF_LM *j)
 Remove the grammar list to be read at startup.
boolean multigram_add_prefix_list (char *prefix_list, char *cwd, JCONF_LM *j, int lmvar)
 Add multiple grammars given by their prefixs to the grammar list.
boolean multigram_add_prefix_filelist (char *listfile, JCONF_LM *j, int lmvar)
 Add multiple grammars from prefix list file to the grammar list.
void schedule_grammar_update (Recog *recog)
 Request engine to check update of all grammar and re-construct the glocal lexicon if needed.
void j_reset_reload (Recog *recog)
 Clear the grammar re-construction flag.
boolean multigram_build (RecogProcess *r)
 Check for global grammar and (re-)build tree lexicon if needed.
int multigram_add (DFA_INFO *dfa, WORD_INFO *winfo, char *name, PROCESS_LM *lm)
 Add a new grammar to the current list of grammars.
boolean multigram_delete (int delid, PROCESS_LM *lm)
 Mark a grammar in the grammar list to be deleted at the next grammar update.
void multigram_delete_all (PROCESS_LM *lm)
 Mark all grammars to be deleted at next grammar update.
int multigram_activate (int gid, PROCESS_LM *lm)
 Activate a grammar in the grammar list.
int multigram_deactivate (int gid, PROCESS_LM *lm)
 Deactivate a grammar in the grammar list.
boolean multigram_update (PROCESS_LM *lm)
 Update global grammar if needed.
int multigram_get_all_num (PROCESS_LM *lm)
 Get the number of current grammars (both active and inactive).
int multigram_get_gram_from_category (int category, PROCESS_LM *lm)
 Get which grammar the given category belongs to.
int multigram_get_gram_from_wid (WORD_ID wid, PROCESS_LM *lm)
 Get which grammar the given word belongs to.
int multigram_get_id_by_name (PROCESS_LM *lm, char *gramname)
 Return a grammar ID of the given grammar name.
MULTIGRAMmultigram_get_grammar_by_name (PROCESS_LM *lm, char *gramname)
 Find a grammar in LM by its name.
MULTIGRAMmultigram_get_grammar_by_id (PROCESS_LM *lm, unsigned short id)
 Find a grammar in LM by its ID number.
boolean multigram_add_words_to_grammar (PROCESS_LM *lm, MULTIGRAM *m, WORD_INFO *winfo)
 Append words to a grammar.
boolean multigram_add_words_to_grammar_by_name (PROCESS_LM *lm, char *gramname, WORD_INFO *winfo)
 Append words to a grammar, given by its name.
boolean multigram_add_words_to_grammar_by_id (PROCESS_LM *lm, unsigned short id, WORD_INFO *winfo)
 Append words to a grammar, given by its ID number.

Detailed Description

Functions to manage grammars or word dictionaries at run time.


Function Documentation

void multigram_add_gramlist ( char *  dfafile,
char *  dictfile,
JCONF_LM j,
int  lmvar 
)

Add a grammar to the grammar list to be read at startup.

Parameters:
dfafile [in] DFA file
dictfile [in] dictionary file
j [in] LM configuration variables
lmvar [in] LM type variant id

Definition at line 66 of file gramlist.c.

Referenced by j_load_lm(), multigram_add_prefix_filelist(), and multigram_add_prefix_list().

Here is the caller graph for this function:

void multigram_remove_gramlist ( JCONF_LM j  ) 

Remove the grammar list to be read at startup.

Parameters:
j [in] LM configuration variables

Definition at line 103 of file gramlist.c.

Referenced by opt_parse(), and opt_release().

Here is the caller graph for this function:

boolean multigram_add_prefix_list ( char *  prefix_list,
char *  cwd,
JCONF_LM j,
int  lmvar 
)

Add multiple grammars given by their prefixs to the grammar list.

This function read in several grammars, given a prefix string that contains a list of file prefixes separated by comma: "foo" or "foo,bar". For each prefix, string ".dfa" and ".dict" will be appended to read dfa file and dict file. The read grammars will be added to the grammar list.

Parameters:
prefix_list [in] string that contains comma-separated list of grammar path prefixes
cwd [in] string of current working directory
j [in] LM configuration variables
lmvar [in] LM type variant id

Definition at line 163 of file gramlist.c.

Referenced by opt_parse().

Here is the caller graph for this function:

boolean multigram_add_prefix_filelist ( char *  listfile,
JCONF_LM j,
int  lmvar 
)

Add multiple grammars from prefix list file to the grammar list.

This function read in multiple grammars at once, given a file that contains a list of grammar prefixes, each per line.

For each prefix, string ".dfa" and ".dict" will be appended to read the corresponding dfa and dict file. The read grammars will be added to the grammar list.

Parameters:
listfile [in] path of the prefix list file
j [in] LM configuration variables
lmvar [in] LM type variant id

Definition at line 265 of file gramlist.c.

Referenced by opt_parse().

Here is the caller graph for this function:

void schedule_grammar_update ( Recog recog  ) 

Request engine to check update of all grammar and re-construct the glocal lexicon if needed.

The actual update will be done between input segment. This function should be called after some grammars are modified.

Parameters:
recog [in] engine instance

Definition at line 170 of file jfunc.c.

void j_reset_reload ( Recog recog  ) 

Clear the grammar re-construction flag.

Parameters:
recog [in] engine instance

Definition at line 215 of file jfunc.c.

Referenced by j_recognize_stream_core().

Here is the caller graph for this function:

boolean multigram_build ( RecogProcess r  ) 

Check for global grammar and (re-)build tree lexicon if needed.

If any modification of the global grammar has been occured, the tree lexicons and some other data for recognition will be re-constructed from the updated global grammar.

Parameters:
r [in] recognition process instance
Returns:
TRUE on success, FALSE on error.

Definition at line 173 of file multi-gram.c.

Referenced by j_launch_recognition_instance(), and j_recognize_stream_core().

Here is the caller graph for this function:

int multigram_add ( DFA_INFO dfa,
WORD_INFO winfo,
char *  name,
PROCESS_LM lm 
)

Add a new grammar to the current list of grammars.

The list of grammars which the LM instance keeps currently is at lm->grammars. The new grammar is flaged at "newbie" and "active", to be treated properly at the next grammar update check.

Parameters:
dfa [in] DFA information of the new grammar.
winfo [in] dictionary information of the new grammar.
name [in] name string of the new grammar.
lm [i/o] LM processing instance
Returns:
the new grammar ID for the given grammar.

Definition at line 277 of file multi-gram.c.

Referenced by multigram_read_file_and_add().

Here is the caller graph for this function:

boolean multigram_delete ( int  delid,
PROCESS_LM lm 
)

Mark a grammar in the grammar list to be deleted at the next grammar update.

Parameters:
delid [in] grammar id to be deleted
lm [i/o] LM processing instance
Returns:
TRUE on normal exit, or FALSE if the specified grammar is not found in the grammar list.

Definition at line 332 of file multi-gram.c.

void multigram_delete_all ( PROCESS_LM lm  ) 

Mark all grammars to be deleted at next grammar update.

Parameters:
lm [i/o] LM processing instance

Definition at line 365 of file multi-gram.c.

int multigram_activate ( int  gid,
PROCESS_LM lm 
)

Activate a grammar in the grammar list.

The specified grammar will only be marked as to be activated in the next grammar update timing.

Parameters:
gid [in] grammar ID to be activated
lm [i/o] LM processing instance
Returns:
0 on success, -1 on error (when specified grammar not found), of 1 if already active

Definition at line 445 of file multi-gram.c.

int multigram_deactivate ( int  gid,
PROCESS_LM lm 
)

Deactivate a grammar in the grammar list.

The words of the de-activated grammar will not be expanded in the recognition process. This feature enables rapid switching of grammars without re-building tree lexicon. The de-activated grammar will again be activated by calling multigram_activate().

Parameters:
gid [in] grammar ID to be de-activated
lm [i/o] LM processing instance
Returns:
0 on success, -1 on error (when specified grammar not found), of 1 if already inactive

Definition at line 507 of file multi-gram.c.

boolean multigram_update ( PROCESS_LM lm  ) 

Update global grammar if needed.

This function checks for any modification in the grammar list from previous call, and update the global grammar if needed.

If there are grammars marked to be deleted in the grammar list, they will be actually deleted from memory. Then the global grammar is built from scratch using the rest grammars. If there are new grammars, they are appended to the current global grammar.

Parameters:
lm [i/o] LM processing instance
Returns:
TRUE when any of add/delete/active/inactive occurs, or FALSE if nothing modified.

Definition at line 619 of file multi-gram.c.

Referenced by j_load_lm(), and j_recognize_stream_core().

Here is the caller graph for this function:

int multigram_get_all_num ( PROCESS_LM lm  ) 

Get the number of current grammars (both active and inactive).

Parameters:
lm [i/o] LM processing instance
Returns:
the number of grammars.

Definition at line 926 of file multi-gram.c.

Referenced by j_recognize_stream_core(), outfile_sentence(), output_result(), and store_result_pass2().

Here is the caller graph for this function:

int multigram_get_gram_from_category ( int  category,
PROCESS_LM lm 
)

Get which grammar the given category belongs to.

Parameters:
category word category ID
lm [i/o] LM processing instance
Returns:
the id of the belonging grammar.

Definition at line 958 of file multi-gram.c.

Referenced by store_result_pass2().

Here is the caller graph for this function:

int multigram_get_gram_from_wid ( WORD_ID  wid,
PROCESS_LM lm 
)

Get which grammar the given word belongs to.

Parameters:
wid word ID
lm [i/o] LM processing instance
Returns:
the id of the belonging grammar.

Definition at line 995 of file multi-gram.c.

int multigram_get_id_by_name ( PROCESS_LM lm,
char *  gramname 
)

Return a grammar ID of the given grammar name.

Parameters:
lm [in] LM process instance
gramname [in] grammar name
Returns:
grammar ID, or -1 if not found.

Definition at line 1060 of file multi-gram.c.

MULTIGRAM* multigram_get_grammar_by_name ( PROCESS_LM lm,
char *  gramname 
)

Find a grammar in LM by its name.

Parameters:
lm [in] LM process instance
gramname [in] grammar name
Returns:
poitner to the grammar, or NULL if not found.

Definition at line 1093 of file multi-gram.c.

Referenced by multigram_add_words_to_grammar_by_name().

Here is the caller graph for this function:

MULTIGRAM* multigram_get_grammar_by_id ( PROCESS_LM lm,
unsigned short  id 
)

Find a grammar in LM by its ID number.

Parameters:
lm [in] LM process instance
id [in] ID number
Returns:
poitner to the grammar, or NULL if not found.

Definition at line 1126 of file multi-gram.c.

Referenced by multigram_add_words_to_grammar_by_id().

Here is the caller graph for this function:

boolean multigram_add_words_to_grammar ( PROCESS_LM lm,
MULTIGRAM m,
WORD_INFO winfo 
)

Append words to a grammar.

Category IDs of grammar in the adding words will be copied as is to the target grammar, so they should be set beforehand correctly. The whole tree lexicon will be rebuilt later.

Currently adding words to N-gram LM is not supported yet.

Parameters:
lm [i/o] LM process instance
m [i/o] grammar to which the winfo will be appended
winfo [in] words to be added to the grammar
Returns:
TRUE on success, or FALSE on failure.

Definition at line 1175 of file multi-gram.c.

Referenced by multigram_add_words_to_grammar_by_id(), and multigram_add_words_to_grammar_by_name().

Here is the caller graph for this function:

boolean multigram_add_words_to_grammar_by_name ( PROCESS_LM lm,
char *  gramname,
WORD_INFO winfo 
)

Append words to a grammar, given by its name.

Call multigram_add_words_to_grammar() with target grammar specified by its name.

Parameters:
lm [i/o] LM process instance
gramname [in] name of the grammar to which the winfo will be appended
winfo [in] words to be added to the grammar
Returns:
TRUE on success, or FALSE on failure.

Definition at line 1228 of file multi-gram.c.

boolean multigram_add_words_to_grammar_by_id ( PROCESS_LM lm,
unsigned short  id,
WORD_INFO winfo 
)

Append words to a grammar, given by its ID number.

Call multigram_add_words_to_grammar() with target grammar specified by its number.

Parameters:
lm [i/o] LM process instance
id [in] ID number of the grammar to which the winfo will be appended
winfo [in] words to be added to the grammar
Returns:
TRUE on success, or FALSE on failure.

Definition at line 1259 of file multi-gram.c.


Generated on Thu Jul 23 12:14:32 2009 for Julius by  doxygen 1.5.1