1/* 2 * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16/** 17 * @file picoktab.h 18 * 19 * symbol tables needed at runtime 20 * 21 * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland 22 * All rights reserved. 23 * 24 * History: 25 * - 2009-04-20 -- initial version 26 * 27 */ 28/** 29 * @addtogroup picoktab 30 31 * <b> Symbol tables needed at runtime </b>\n 32 * 33*/ 34 35#ifndef PICOKTAB_H_ 36#define PICOKTAB_H_ 37 38#include "picoos.h" 39#include "picoknow.h" 40 41#ifdef __cplusplus 42extern "C" { 43#endif 44#if 0 45} 46#endif 47 48 49/* ************************************************************/ 50/* fixed IDs type and functions */ 51/* ************************************************************/ 52 53/** object : FixedIds 54 * shortcut : ids 55 */ 56typedef struct picoktab_fixed_ids * picoktab_FixedIds; 57 58typedef struct picoktab_fixed_ids { 59 picoos_uint8 phonStartId; 60 picoos_uint8 phonTermId; 61} picoktab_fixed_ids_t; 62 63/* to be used by picorsrc only */ 64pico_status_t picoktab_specializeIdsKnowledgeBase(picoknow_KnowledgeBase this, 65 picoos_Common common); 66 67picoktab_FixedIds picoktab_getFixedIds(picoknow_KnowledgeBase this); 68 69 70/* ************************************************************/ 71/* Graphs type and functions */ 72/* ************************************************************/ 73 74typedef struct picoktab_graphs *picoktab_Graphs; 75 76/* to be used by picorsrc only */ 77pico_status_t picoktab_specializeGraphsKnowledgeBase(picoknow_KnowledgeBase this, 78 picoos_Common common); 79 80/* return kb graphs for usage in PU */ 81picoktab_Graphs picoktab_getGraphs(picoknow_KnowledgeBase this); 82 83/* graph access routine: if the desired graph 'utf8graph' exists in 84 the graph table a graph offset > 0 is returned, which then can be 85 used to access the properties */ 86picoos_uint32 picoktab_graphOffset(const picoktab_Graphs this, 87 picoos_uchar * utf8graph); 88 89 90/* check if UTF8 char 'graph' has property vowellike, return non-zero 91 if 'ch' has the property, 0 otherwise */ 92picoos_uint8 picoktab_hasVowellikeProp(const picoktab_Graphs this, 93 const picoos_uint8 *graph, 94 const picoos_uint8 graphlenmax); 95 96/* graph properties access routines: if graph with offset 'graphsOffset' has the 97 desired property, returns TRUE if 'ch' has the property, FALSE otherwise */ 98picoos_bool picoktab_getIntPropTokenType(const picoktab_Graphs this, 99 picoos_uint32 graphsOffset, 100 picoos_uint8 *stokenType); 101picoos_bool picoktab_getIntPropTokenSubType(const picoktab_Graphs this, 102 picoos_uint32 graphsOffset, 103 picoos_int8 *stokenSubType); 104picoos_bool picoktab_getIntPropValue(const picoktab_Graphs this, 105 picoos_uint32 graphsOffset, 106 picoos_uint32 *value); 107picoos_bool picoktab_getStrPropLowercase(const picoktab_Graphs this, 108 picoos_uint32 graphsOffset, 109 picoos_uchar *lowercase); 110picoos_bool picoktab_getStrPropGraphsubs1(const picoktab_Graphs this, 111 picoos_uint32 graphsOffset, 112 picoos_uchar *graphsubs1); 113picoos_bool picoktab_getStrPropGraphsubs2(const picoktab_Graphs this, 114 picoos_uint32 graphsOffset, 115 picoos_uchar *graphsubs2); 116picoos_bool picoktab_getIntPropPunct(const picoktab_Graphs this, 117 picoos_uint32 graphsOffset, 118 picoos_uint8 *info1, 119 picoos_uint8 *info2); 120 121picoos_uint16 picoktab_graphsGetNumEntries(const picoktab_Graphs this); 122void picoktab_graphsGetGraphInfo(const picoktab_Graphs this, 123 picoos_uint16 graphIndex, picoos_uchar * from, picoos_uchar * to, 124 picoos_uint8 * propset, 125 picoos_uint8 * stokenType, picoos_uint8 * stokenSubType, 126 picoos_uint8 * value, picoos_uchar * lowercase, 127 picoos_uchar * graphsubs1, picoos_uchar * graphsubs2, 128 picoos_uint8 * punct); 129 130 131/* ************************************************************/ 132/* Phones type and functions */ 133/* ************************************************************/ 134 135/* to be used by picorsrc only */ 136pico_status_t picoktab_specializePhonesKnowledgeBase(picoknow_KnowledgeBase this, 137 picoos_Common common); 138 139typedef struct picoktab_phones *picoktab_Phones; 140 141/* return kb Phones for usage in PU */ 142picoktab_Phones picoktab_getPhones(picoknow_KnowledgeBase this); 143 144/* check if 'ch' has a property, return non-zero if 'ch' has the 145 property, 0 otherwise */ 146picoos_uint8 picoktab_hasVowelProp(const picoktab_Phones this, 147 const picoos_uint8 ch); 148picoos_uint8 picoktab_hasDiphthProp(const picoktab_Phones this, 149 const picoos_uint8 ch); 150picoos_uint8 picoktab_hasGlottProp(const picoktab_Phones this, 151 const picoos_uint8 ch); 152picoos_uint8 picoktab_hasNonsyllvowelProp(const picoktab_Phones this, 153 const picoos_uint8 ch); 154picoos_uint8 picoktab_hasSyllconsProp(const picoktab_Phones this, 155 const picoos_uint8 ch); 156 157/* to speed up processing for often used combinations of properties 158 the following functions are provided, which check if the property 159 combination is true for 'ch' */ 160picoos_bool picoktab_isSyllCarrier(const picoktab_Phones this, 161 const picoos_uint8 ch); 162 163/* some properties can be assigned to a single sym only, check if 'ch' 164 is a special sym, return TRUE if it is the special sym, FALSE 165 otherwise */ 166picoos_bool picoktab_isPrimstress(const picoktab_Phones this, 167 const picoos_uint8 ch); 168picoos_bool picoktab_isSecstress(const picoktab_Phones this, 169 const picoos_uint8 ch); 170picoos_bool picoktab_isSyllbound(const picoktab_Phones this, 171 const picoos_uint8 ch); 172picoos_bool picoktab_isWordbound(const picoktab_Phones this, 173 const picoos_uint8 ch); 174picoos_bool picoktab_isPause(const picoktab_Phones this, 175 const picoos_uint8 ch); 176 177/* get specific sym values */ 178picoos_uint8 picoktab_getPrimstressID(const picoktab_Phones this); 179picoos_uint8 picoktab_getSecstressID(const picoktab_Phones this); 180picoos_uint8 picoktab_getSyllboundID(const picoktab_Phones this); 181picoos_uint8 picoktab_getWordboundID(const picoktab_Phones this); 182picoos_uint8 picoktab_getPauseID(const picoktab_Phones this); 183 184/* ************************************************************/ 185/* Pos type and functions */ 186/* ************************************************************/ 187 188/* to be used by picorsrc only */ 189pico_status_t picoktab_specializePosKnowledgeBase(picoknow_KnowledgeBase this, 190 picoos_Common common); 191 192typedef struct picoktab_pos *picoktab_Pos; 193 194#define PICOKTAB_MAXNRPOS_IN_COMB 8 195 196/* return kb Pos for usage in PU */ 197picoktab_Pos picoktab_getPos(picoknow_KnowledgeBase this); 198 199/* returns TRUE if 'pos' is the ID of a unique (ie. non-combined) POS, 200 returns FALSE otherwise */ 201picoos_bool picoktab_isUniquePos(const picoktab_Pos this, 202 const picoos_uint8 pos); 203 204/* returns TRUE if the non-combined 'pos' is one of the POSes in the 205 combined POS group 'posgroup, returns FALSE otherwise. Note: if 206 'posgroup' is itself non-combined, this function returns TRUE if it 207 matches with 'pos', and FALSE otherwise */ 208picoos_bool picoktab_isPartOfPosGroup(const picoktab_Pos this, 209 const picoos_uint8 pos, 210 const picoos_uint8 posgroup); 211 212/* return the combined POS group ID that is a representative ID for 213 all the 'poslistlen' POSes (which can be combined themselves) in 214 poslist. Returns '0' in case of error. */ 215picoos_uint8 picoktab_getPosGroup(const picoktab_Pos this, 216 const picoos_uint8 *poslist, 217 const picoos_uint8 poslistlen); 218 219#ifdef __cplusplus 220} 221#endif 222 223 224#endif /*PICOKTAB_H_*/ 225