libsent/src/dfa/cpair.c File Reference

Category-pair constraint handling. More...

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

Go to the source code of this file.

Functions

static int cp_find (int *list, int len, int key, int *loc)
 Search for a terminal ID in a cp list.
boolean dfa_cp (DFA_INFO *dfa, int i, int j)
 Return whether the given two category can be connected or not.
boolean dfa_cp_begin (DFA_INFO *dfa, int i)
 Return whether the category can be appear at the beginning of sentence.
boolean dfa_cp_end (DFA_INFO *dfa, int i)
 Return whether the category can be appear at the end of sentence.
static boolean cp_add (int **list, int *len, int *alloclen, int val, int loc)
 Add an terminal ID to a specified location in the cp list.
static boolean cp_remove (int **list, int *len, int loc)
 Remove an element from the cp list.
void set_dfa_cp (DFA_INFO *dfa, int i, int j, boolean value)
 Set a category-pair matrix bit.
void set_dfa_cp_begin (DFA_INFO *dfa, int i, boolean value)
 Set a category-pair matrix bit for the beginning of sentence.
void set_dfa_cp_end (DFA_INFO *dfa, int i, boolean value)
 Set a category-pair matrix bit for the end of sentence.
void init_dfa_cp (DFA_INFO *dfa)
 Initialize category pair matrix in the grammar data.
void malloc_dfa_cp (DFA_INFO *dfa, int term_num, int size)
 Allocate memory for category pair matrix and initialize it.
boolean dfa_cp_append (DFA_INFO *dfa, DFA_INFO *src, int offset)
 Append a categori-pair matrix to another.
void free_dfa_cp (DFA_INFO *dfa)
 Free the category pair matrix from DFA grammar.
void dfa_cp_output_rawdata (FILE *fp, DFA_INFO *dfa)
void dfa_cp_count_size (DFA_INFO *dfa, unsigned long *size_ret, unsigned long *allocsize_ret)


Detailed Description

Category-pair constraint handling.

Functions to allocate memory for category-pair constraint, and functions to return whether the given category pairs can be connected or not are defined here.

Author:
Akinobu LEE
Date:
Tue Feb 15 13:54:44 2005
Revision
1.4

Definition in file cpair.c.


Function Documentation

static int cp_find ( int *  list,
int  len,
int  key,
int *  loc 
) [static]

Search for a terminal ID in a cp list.

Set its location to loc. When not found, the location where to insert the key data iwill be set.

Parameters:
list [in] cp list
len [in] length of list
key [in] a terminal ID value to find
loc [out] return the to-be-inserted location of the key
Returns:
its location when found, or -1 when not found.

Definition at line 47 of file cpair.c.

Referenced by dfa_cp(), dfa_cp_begin(), dfa_cp_end(), set_dfa_cp(), set_dfa_cp_begin(), and set_dfa_cp_end().

boolean dfa_cp ( DFA_INFO dfa,
int  i,
int  j 
)

Return whether the given two category can be connected or not.

Parameters:
dfa [in] DFA grammar holding category pair matrix
i [in] category id of left word
j [in] category id of right word
Returns:
TRUE if connection is allowed by the grammar, FALSE if prohibited.

Definition at line 91 of file cpair.c.

Referenced by beam_inter_word(), can_succeed(), lcdset_register_with_category(), and lcdset_register_with_category_all().

boolean dfa_cp_begin ( DFA_INFO dfa,
int  i 
)

Return whether the category can be appear at the beginning of sentence.

Parameters:
dfa [in] DFA grammar holding category pair matrix
i [in] category id of the word
Returns:
TRUE if it can appear at the beginning of sentence, FALSE if not.

Definition at line 109 of file cpair.c.

Referenced by can_succeed(), and init_nodescore().

boolean dfa_cp_end ( DFA_INFO dfa,
int  i 
)

Return whether the category can be appear at the end of sentence.

Parameters:
dfa [in] DFA grammar holding category pair matrix
i [in] category id of the word
Returns:
TRUE if it can appear at the end of sentence, FALSE if not.

Definition at line 126 of file cpair.c.

static boolean cp_add ( int **  list,
int *  len,
int *  alloclen,
int  val,
int  loc 
) [static]

Add an terminal ID to a specified location in the cp list.

Parameters:
list [i/o] cp list
len [i/o] data num in the list
alloclen [i/o] allocated length of the list
val [in] value to be added
loc [in] location where to add the val
Returns:
TRUE on success, FALSE on failure.

Definition at line 147 of file cpair.c.

Referenced by set_dfa_cp(), set_dfa_cp_begin(), and set_dfa_cp_end().

static boolean cp_remove ( int **  list,
int *  len,
int  loc 
) [static]

Remove an element from the cp list.

Parameters:
list [i/o] cp list
len [i/o] data num in the list
loc [in] location of removing value
Returns:
TRUE on success, FALSE on error.

Definition at line 176 of file cpair.c.

Referenced by set_dfa_cp(), set_dfa_cp_begin(), and set_dfa_cp_end().

void set_dfa_cp ( DFA_INFO dfa,
int  i,
int  j,
boolean  value 
)

Set a category-pair matrix bit.

Parameters:
dfa [out] DFA grammar holding category pair matrix
i [in] category id of left word
j [in] category id of right word
value TRUE if connection allowed, FALSE if connection prohibited.

Definition at line 200 of file cpair.c.

void set_dfa_cp_begin ( DFA_INFO dfa,
int  i,
boolean  value 
)

Set a category-pair matrix bit for the beginning of sentence.

Parameters:
dfa [out] DFA grammar holding category pair matrix
i [in] category id of the word
value TRUE if the category can appear at the beginning of sentence, FALSE if not.

Definition at line 225 of file cpair.c.

void set_dfa_cp_end ( DFA_INFO dfa,
int  i,
boolean  value 
)

Set a category-pair matrix bit for the end of sentence.

Parameters:
dfa [out] DFA grammar holding category pair matrix
i [in] category id of the word
value TRUE if the category can appear at the end of sentence, FALSE if not.

Definition at line 251 of file cpair.c.

Referenced by extract_cpair().

void init_dfa_cp ( DFA_INFO dfa  ) 

Initialize category pair matrix in the grammar data.

Parameters:
dfa [out] DFA grammar to hold category pair matrix

Definition at line 274 of file cpair.c.

Referenced by dfa_info_new().

void malloc_dfa_cp ( DFA_INFO dfa,
int  term_num,
int  size 
)

Allocate memory for category pair matrix and initialize it.

Parameters:
dfa [out] DFA grammar to hold category pair matrix
term_num [in] number of categories in the grammar
size [in] memory allocation length for each cp list as initial

Definition at line 287 of file cpair.c.

Referenced by extract_cpair().

boolean dfa_cp_append ( DFA_INFO dfa,
DFA_INFO src,
int  offset 
)

Append a categori-pair matrix to another.

This function assumes that other grammar information has been already appended and dfa->term_num contains the new size.

Parameters:
dfa [i/o] DFA grammar to which the new category pair will be appended
src [in] source DFA
offset [in] appending point at dfa
Returns:
TRUE on success, FALSE on error.

Definition at line 319 of file cpair.c.

Referenced by cpair_append().

void free_dfa_cp ( DFA_INFO dfa  ) 

Free the category pair matrix from DFA grammar.

Parameters:
dfa [i/o] DFA grammar holding category pair matrix

Definition at line 396 of file cpair.c.

Referenced by dfa_info_free().


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