Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

multi-gram.c File Reference

Management of Recognition grammars for Julian. More...

#include <julius.h>

Include dependency graph for multi-gram.c:

Go to the source code of this file.

Defines

#define MDEBUG
 For debug: define this if you want grammar update messages to stdout.

Functions

static void multigram_setup (DFA_INFO *d, WORD_INFO *w)
 Setup informations for recognition with the given grammar.
static void print_all_gram ()
static void send_gram_info ()
static void multigram_build_append (DFA_INFO *gdfa, WORD_INFO *gwinfo, MULTIGRAM *m)
void multigram_add (DFA_INFO *dfa, WORD_INFO *winfo, char *name)
boolean multigram_delete (int delid)
void multigram_delete_all ()
static boolean multigram_exec_delete ()
void multigram_activate (int gid)
void multigram_deactivate (int gid)
static boolean multigram_exec_activate ()
boolean multigram_exec ()
 Update and re-construct global grammar if needed.
void multigram_read_file (char *dfa_file, char *dict_file)
void multigram_add_gramlist (char *dfafile, char *dictfile)
void multigram_remove_gramlist ()
void multigram_read_all_gramlist ()
void multigram_add_prefix_list (char *prefix_list, char *cwd)
 Add multiple grammars given by their prefixs to the grammar list.
void multigram_add_prefix_filelist (char *listfile)
 Add multiple grammars from prefix list file to the grammar list.
int multigram_get_all_num ()
int multigram_get_gram_from_category (int category)

Variables

static DFA_INFOglobal_dfa = NULL
static WORD_INFOglobal_winfo = NULL
static int gram_maxid = 0
static char * hookstr [] = {"", "delete", "activate", "deactivate"}
 Grammar status to be processed in the next reload timing.


Detailed Description

Management of Recognition grammars for Julian.

Author:
Akinobu Lee
Date:
Sat Jun 18 23:45:18 2005
This file contains functions to read and manage recognition grammar. These function read in grammar and dictionary, and setup data for recognition.

Recognition with multiple grammars are supported. Julian can read several grammars specified at startup time, and perform recognition with those grammars simultaneously. In module mode, you can add / delete / activate / deactivate each grammar while performing recognition, and also can output optimum results for each grammar.

Internally, the given grammars are composed to a single Global Grammar. The global grammar will be updated whenever a new grammar has been read or deleted. The syntax rule (DFA) of the global grammar will be stored at global_dfa, and the corresponding dictionary will be at global_winfo locally, independent of the decoding timing. After that, multigram_setup() will be called to make the prepared global grammar to be used in the actual recognition process, by copying the grammar and the dictionary to the global variable dfa and winfo.

Revision
1.2

Definition in file multi-gram.c.


Function Documentation

static void multigram_setup DFA_INFO d,
WORD_INFO w
[static]
 

Setup informations for recognition with the given grammar.

This function will re-construct the tree lexicon using the given grammar and dictionary to prepare for the recognition. If explicit value is not specified for the beam width on startup, it also resets the beam width according to the size of the new dictionary. The given grammars (DFA and dictionary) and the rebuilt tree lexicon will be set to the global variables "dfa", "winfo" and "wchmm" to be accessible from recognition functions.

Parameters:
d [in] DFA grammar information
w [in] dictionary information.

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

Referenced by multigram_exec().

static void print_all_gram  )  [static]
 

Output current list of grammars to stdout.

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

Referenced by multigram_add(), and multigram_exec().

static void send_gram_info  )  [static]
 

Send current list of grammars to module client.

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

Referenced by multigram_add(), and multigram_exec().

static void multigram_build_append DFA_INFO gdfa,
WORD_INFO gwinfo,
MULTIGRAM m
[static]
 

Install a new grammar to the existing one.

Parameters:
gdfa [i/o] DFA information of the existing grammar to which the m will be installed.
gwinfo [i/o] Dictionary information of the existing grammar to which the m will be installed.
m [i/o] New grammar information to be installed. The resulting location of the grammar within gdfa and gwinfo will be stored in the data.

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

Referenced by multigram_exec().

void multigram_add DFA_INFO dfa,
WORD_INFO winfo,
char *  name
 

Add a new grammar to the current list of grammars.

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.

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

Referenced by multigram_read_file().

boolean multigram_delete int  delid  ) 
 

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

Parameters:
delid [in] grammar id to be deleted
Returns:
TRUE on normal exit, or FALSE if the specified grammar is not found in the grammar list.

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

void multigram_delete_all  ) 
 

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

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

static boolean multigram_exec_delete  )  [static]
 

Purge grammars that has been marked as delete.

Returns:
TRUE if the global grammar must be re-constructed, or FALSE if not needed.

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

Referenced by multigram_exec().

void multigram_activate int  gid  ) 
 

Activate specified 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

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

void multigram_deactivate int  gid  ) 
 

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

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

static boolean multigram_exec_activate  )  [static]
 

Execute (de)activation of grammars previously marked as so.

Returns:
TRUE if at least one grammar has been changed, or FALSE if no grammar has changed its status.

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

Referenced by multigram_exec().

boolean multigram_exec  ) 
 

Update and re-construct 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.

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

Returns:
always TRUE.

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

Referenced by final_fusion(), and main_recognition_loop().

void multigram_read_file char *  dfa_file,
char *  dict_file
 

Read in dfa file and dict file, and add them to the grammar list.

Parameters:
dfa_file [in] dfa file name
dict_file [in] dict file name

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

Referenced by multigram_read_all_gramlist().

void multigram_add_gramlist char *  dfafile,
char *  dictfile
 

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

Parameters:
dfafile [in] DFA file
dictfile [in] dictionary file

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

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

void multigram_remove_gramlist  ) 
 

Remove the grammar list to be read at startup.

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

Referenced by opt_parse().

void multigram_read_all_gramlist  ) 
 

Read in all the grammars specified at startup.

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

Referenced by final_fusion().

void multigram_add_prefix_list char *  prefix_list,
char *  cwd
 

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

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

Referenced by opt_parse().

void multigram_add_prefix_filelist char *  listfile  ) 
 

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

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

Referenced by opt_parse().

int multigram_get_all_num  ) 
 

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

Returns:
the number of grammars.

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

Referenced by ttyout_pass2().

int multigram_get_gram_from_category int  category  ) 
 

Get which grammar the given category belongs to.

Parameters:
category word category ID
Returns:
the id of the belonging grammar.

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

Referenced by msock_pass2(), and ttyout_pass2().


Variable Documentation

DFA_INFO* global_dfa = NULL [static]
 

Pointer to hold DFA information of the current global grammar. This is used to build a global grammar.

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

WORD_INFO* global_winfo = NULL [static]
 

Pointer to hold vocabulary information of the current global grammar. This is used to build a global grammar.

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

int gram_maxid = 0 [static]
 

Current maximum value of assigned grammar ID. A new grammar ID will be assigned to each new grammar.

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

Referenced by multigram_add().


Generated on Tue Mar 28 16:18:03 2006 for Julius by  doxygen 1.4.2