Home | History | Annotate | Download | only in include
      1 /*---------------------------------------------------------------------------*
      2  *  lts_seq_internal.h  *
      3  *                                                                           *
      4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
      5  *                                                                           *
      6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
      7  *  you may not use this file except in compliance with the License.         *
      8  *                                                                           *
      9  *  You may obtain a copy of the License at                                  *
     10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
     11  *                                                                           *
     12  *  Unless required by applicable law or agreed to in writing, software      *
     13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
     14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
     15  *  See the License for the specific language governing permissions and      *
     16  *  limitations under the License.                                           *
     17  *                                                                           *
     18  *---------------------------------------------------------------------------*/
     19 
     20 
     21 
     22 #ifndef _LTS_SEQ_INTERNAL_H__
     23 #define _LTS_SEQ_INTERNAL_H__
     24 
     25 #define NO_NODE 10000
     26 #define MAX_WORD_LEN 50
     27 #define LTS_MAXCHAR 255
     28 #define MAX_CONS_COMB 100
     29 #define MAX_NUM_CONTEXT 5
     30 #define NUM_STRESS_LVL 3 /* SS1, SS2, SS0 */
     31 
     32 /*
     33  * Question types:
     34  * this enum cannot be changed for a given DATA file
     35  */
     36 
     37 typedef enum {
     38   UnKnown = 0,
     39   Left1,
     40   Left2,
     41   Left3,
     42   Left4,
     43   Left5,     /*5*/
     44   Right1,
     45   Right2,
     46   Right3,
     47   Right4,
     48   Right5,    /*10*/
     49   LeftPhone1,
     50   LetInWord,
     51   SylInWord,
     52   WordLen,
     53   Syl2InWord, /*15*/
     54   SylInRoot,
     55   Syl2InRoot,
     56   LeftString,
     57   RightString,
     58   Left_DFRE,      /*20*/  /*DFRE = distance from root edge*/
     59   Right_DFRE,      /*DFRE = distance from root edge*/
     60   NumQuestionTypes
     61 } QuestionType;
     62 
     63 typedef struct LQUESTION {
     64   unsigned char num_list;
     65   unsigned char type;
     66   unsigned char *list;	/*list of items to match against for question*/
     67   unsigned short membership[16]; // UCHAR_MAX/sizeof(unsigned short)/8
     68 
     69 } LQUESTION;
     70 
     71 #ifdef SKIP_LDP_PROPERTIES
     72 typedef struct LDP {
     73   unsigned char letter;
     74   unsigned char left_context[MAX_NUM_CONTEXT];
     75   unsigned char right_context[MAX_NUM_CONTEXT];
     76   char left_phone1;
     77   char let_in_word;
     78   char syl_in_word;
     79   char syl2_in_word;
     80   char syl_in_root;
     81   char syl2_in_root;
     82   char word_len;
     83   int left_string_index;
     84   int right_string_index;
     85   int left_DFRE;  /*DFRE = distance from root edge*/
     86   int right_DFRE;
     87 } LDP;
     88 #else
     89 typedef struct LDP {
     90   unsigned char letter;
     91   int properties[ NumQuestionTypes];
     92 } LDP;
     93 #endif
     94 
     95 
     96 /*RT tree is the compact representations of the trees
     97   Got rid of the NODE structures in order to save the overhead.
     98 
     99   Instead, the two arrays below are indexed by node_index
    100 */
    101 typedef struct RT_LTREE {
    102   short *values_or_question1;  /*if leaf node, this is the value at the node.  If not, this
    103 				 is the index into the questions*/
    104   short *question2;   /*also used to hold backoff_output for leaf nodes*/
    105   short *left_nodes;   /*right_node_index is always left_nodex+1, so just store left.
    106 			 If = MAX_NODES, then this is a leaf node*/
    107   int num_nodes;
    108 } RT_LTREE;
    109 
    110 
    111 typedef struct LM { /*letter mappings*/
    112   char *letters;
    113   char *type;
    114   int num_letters;
    115   int letter_index_for_letter[UCHAR_MAX+1];
    116 } LM;
    117 
    118 
    119 typedef struct PM { /*phone mappings*/
    120   char **phones;
    121   int num_phones;
    122   void* phoneH; /* hash table if any */
    123 } PM;
    124 
    125 typedef struct LTS {
    126   char **outputs;
    127   char **input_for_output;
    128   int num_outputs;
    129 
    130   char **strings;
    131   int num_strings;
    132   char *string_lens;
    133   unsigned short membership[16]; // UCHAR_MAX/sizeof(unsigned short)/8
    134 
    135   RT_LTREE **trees;
    136   LQUESTION **questions;
    137 
    138   LM *letter_mapping;
    139   PM *phone_mapping;
    140   LDP dp;
    141   char *allowable_cons_comb[MAX_CONS_COMB];
    142   int num_cons_comb;
    143   void* allowable_cons_combH; /* hash table */
    144   int num_letters;
    145   int num_questions;
    146 
    147 } LTS;
    148 
    149 
    150 /* check for combinations of LTS phones to substitute for ETI phones */
    151 /* LTS_ETI_PHONES are defined in a language specific header file slts_phone_def.h */
    152 void replace_eti_phones(char *dest, char *src);
    153 
    154 void *lts_alloc(int num, int size);
    155 
    156 
    157 #endif /* _LTS_SEQ_INTERNAL_H__ */
    158