Home | History | Annotate | Download | only in lib
      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 picokpr.h
     18  *
     19  * knowledge handling for text preprocessing
     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 picokpr
     30 
     31  * <b> Knowledge handling for text preprocessing </b>\n
     32  *
     33 */
     34 
     35 #ifndef PICOKPR_H_
     36 #define PICOKPR_H_
     37 
     38 #include "picoos.h"
     39 #include "picoknow.h"
     40 
     41 #ifdef __cplusplus
     42 extern "C" {
     43 #endif
     44 #if 0
     45 }
     46 #endif
     47 
     48 
     49 /* ************************************************************/
     50 /* function to create specialized kb, */
     51 /* to be used by picorsrc only */
     52 /* ************************************************************/
     53 
     54 pico_status_t picokpr_specializePreprocKnowledgeBase(picoknow_KnowledgeBase this,
     55                                                      picoos_Common common);
     56 
     57 
     58 /* ************************************************************/
     59 /* preproc type and getPreproc function */
     60 /* ************************************************************/
     61 
     62 /* maximal array length in preproc knowledge */
     63 #define NPPMaxStrArrLen       100000000
     64 #define NPPMaxLexCatArrLen    65536
     65 #define NPPMaxAttrValLen      65536
     66 #define NPPMaxOutItemArrLen   65536
     67 #define NPPMaxTokArrLen       65536
     68 #define NPPMaxProdArrLen      65536
     69 #define NPPMaxCtxArrLen       65536
     70 
     71 /* array offset types */
     72 typedef picoos_uint32 picokpr_StrArrOffset;
     73 typedef picoos_uint16 picokpr_LexCatArrOffset;
     74 typedef picoos_uint16 picokpr_AttrValArrOffset;
     75 typedef picoos_uint16 picokpr_OutItemArrOffset;
     76 typedef picoos_uint16 picokpr_TokArrOffset;
     77 typedef picoos_uint16 picokpr_ProdArrOffset;
     78 typedef picoos_uint16 picokpr_CtxArrOffset;
     79 
     80 typedef picoos_uchar * picokpr_VarStrPtr;
     81 
     82 typedef picoos_int16 picokpr_LexCat;
     83 typedef picoos_uint32 picokpr_TokSetNP;
     84 typedef picoos_uint32 picokpr_TokSetWP;
     85 
     86 /* preproc types */
     87 typedef struct picokpr_preproc * picokpr_Preproc;
     88 
     89 /* return kb preproc for usage in PU */
     90 picokpr_Preproc picokpr_getPreproc(picoknow_KnowledgeBase this);
     91 
     92 
     93 /* *****************************************************************************/
     94 /* access routines */
     95 /* *****************************************************************************/
     96 
     97 /* knowledge base access routines for strings in StrArr */
     98 extern picokpr_VarStrPtr picokpr_getVarStrPtr(picokpr_Preproc preproc, picokpr_StrArrOffset ofs);
     99 extern picoos_bool picokpr_isEqual (picokpr_Preproc preproc, picoos_uchar str[], picoos_int32 len__9, picokpr_StrArrOffset str2);
    100 extern picoos_bool picokpr_isEqualHead (picokpr_Preproc preproc, picoos_uchar str[], picoos_int32 len__10, picokpr_StrArrOffset head);
    101 extern picoos_bool picokpr_isEqualMid (picokpr_Preproc preproc, picoos_uchar str[], picoos_int32 len__11, picokpr_StrArrOffset mid);
    102 extern picoos_bool picokpr_isEqualTail (picokpr_Preproc preproc, picoos_uchar str[], picoos_int32 len__12, picokpr_StrArrOffset tail);
    103 
    104 /* knowledge base access routines for lexical categories in LexCatArr */
    105 extern picokpr_LexCat picokpr_getLexCat(picokpr_Preproc preproc, picokpr_LexCatArrOffset ofs);
    106 
    107 /* knowledge base access routines for AttrVal fields in AttrValArr */
    108 extern picoos_int32 picokpr_getAttrValArrInt32(picokpr_Preproc preproc, picokpr_AttrValArrOffset ofs);
    109 
    110 /* knowledge base access routines for out items fields in OutItemArr */
    111 extern picokpr_StrArrOffset picokpr_getOutItemStrOfs(picokpr_Preproc preproc, picokpr_OutItemArrOffset ofs);
    112 extern picokpr_VarStrPtr picokpr_getOutItemStr(picokpr_Preproc preproc, picokpr_OutItemArrOffset ofs);
    113 extern picoos_int32 picokpr_getOutItemType(picokpr_Preproc preproc, picokpr_OutItemArrOffset ofs);
    114 extern picoos_int32 picokpr_getOutItemVal(picokpr_Preproc preproc, picokpr_OutItemArrOffset ofs);
    115 extern picokpr_OutItemArrOffset picokpr_getOutItemArgOfs(picokpr_Preproc preproc, picokpr_OutItemArrOffset ofs);
    116 extern picokpr_OutItemArrOffset picokpr_getOutItemNextOfs(picokpr_Preproc preproc, picokpr_OutItemArrOffset ofs);
    117 
    118 /* knowledge base access routines for tokens in TokArr */
    119 extern picokpr_TokSetNP picokpr_getTokSetNP(picokpr_Preproc preproc, picokpr_TokArrOffset ofs);
    120 extern picokpr_TokSetWP picokpr_getTokSetWP(picokpr_Preproc preproc, picokpr_TokArrOffset ofs);
    121 extern picokpr_TokArrOffset picokpr_getTokNextOfs(picokpr_Preproc preproc, picokpr_TokArrOffset ofs);
    122 extern picokpr_TokArrOffset picokpr_getTokAltLOfs(picokpr_Preproc preproc, picokpr_TokArrOffset ofs);
    123 extern picokpr_TokArrOffset picokpr_getTokAltROfs(picokpr_Preproc preproc, picokpr_TokArrOffset ofs);
    124 extern picokpr_AttrValArrOffset picokpr_getTokAttribOfs(picokpr_Preproc preproc, picokpr_TokArrOffset ofs);
    125 
    126 /* knowledge base access routines for productions in ProdArr */
    127 extern picoos_int32 picokpr_getProdArrLen(picokpr_Preproc preproc);
    128 extern picoos_int32 picokpr_getProdPrefCost(picokpr_Preproc preproc, picokpr_ProdArrOffset ofs);
    129 extern picokpr_StrArrOffset picokpr_getProdNameOfs(picokpr_Preproc preproc, picokpr_ProdArrOffset ofs);
    130 extern picokpr_TokArrOffset picokpr_getProdATokOfs(picokpr_Preproc preproc, picokpr_ProdArrOffset ofs);
    131 extern picokpr_TokArrOffset picokpr_getProdETokOfs(picokpr_Preproc preproc, picokpr_ProdArrOffset ofs);
    132 
    133 /* knowledge base access routines for contexts in CtxArr */
    134 extern picoos_int32 picokpr_getCtxArrLen(picokpr_Preproc preproc);
    135 extern picokpr_StrArrOffset picokpr_getCtxCtxNameOfs(picokpr_Preproc preproc, picokpr_CtxArrOffset ofs);
    136 extern picokpr_StrArrOffset picokpr_getCtxNetNameOfs(picokpr_Preproc preproc, picokpr_CtxArrOffset ofs);
    137 extern picokpr_StrArrOffset picokpr_getCtxProdNameOfs(picokpr_Preproc preproc, picokpr_CtxArrOffset ofs);
    138 
    139 /* knowledge base access routines for preprocs */
    140 extern picokpr_VarStrPtr picokpr_getPreprocNetName(picokpr_Preproc preproc);
    141 
    142 #ifdef __cplusplus
    143 }
    144 #endif
    145 
    146 
    147 #endif /*PICOKPR_H_*/
    148