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 picosa.h
     18  *
     19  * sentence analysis - POS disambiguation - Include file
     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 
     30 /** @addtogroup picosa
     31  * ---------------------------------------------------\n
     32  * <b> Pico Sentence analysis </b>\n
     33  * ---------------------------------------------------\n
     34  *
     35 itemtype, iteminfo1, iteminfo2, content -> TYPE(INFO1,INFO2)content
     36 in the following
     37 
     38 items input
     39 ===========
     40 
     41 processed by sa (POS disambiguation):
     42 - WORDGRAPH(POSes,NA)graph
     43 - WORDINDEX(POSes,NA)POS|1ind1...POSN|indN
     44 - CMD(PICODATA_ITEMINFO1_CMD_FLUSH,PICODATA_ITEMINFO2_NA)
     45 
     46 processed by sa (Phrasing, Accentuation):
     47 - PUNC(PUNCtype,PUNCsubtype)
     48 
     49 unprocessed:
     50 - all other item types are forwarded through the PU without modification:
     51   CMD
     52 
     53 
     54 minimal input size (before processing starts)
     55 ==================
     56 
     57 processing (POS disambiguation, g2p, lexind, phrasing, accentuation)
     58 is possible with
     59 
     60 - one punctuation-phrase, consisting of a sequence (see below for
     61   limits) of items terminated by a PUNC item.
     62 
     63 (possible but not implemented: as long as the internal buffer is
     64 empty, non-processed item types can be processed immediately)
     65 
     66 Ensuring terminal PUNC item:
     67 - when reading items from the external buffer a CMD(...FLUSH...) is
     68   converted to a PUNC(...FLUSH...) item
     69 - If needed, a PUNC(PHRASE) is artificially added to ensure a phrase
     70   fits in the PUs memory and processing can start.
     71 
     72 
     73 items processed and output
     74 ==========================
     75 
     76 precondition:
     77 CMD(...FLUSH...) already converted to PUNC(...FLUSH...) and trailing
     78 PUNC item enforced if necessary.
     79 
     80 ----
     81 1. PROCESS_POSD: processing input WORDGRAPH or WORDINDEX items, after
     82 POS disambiguation (POSes -> POS), results in a sequence of:
     83 
     84 -> WORDGRAPH(POS,NA)graph
     85 -> WORDINDEX(POS,NA)POS|ind
     86 
     87 ----
     88 2. PROCESS_WPHO: then, after lex-index lookup and G2P in a
     89 sequence of:
     90 
     91 -> WORDPHON(POS,NA)phon
     92 
     93 (phon containing primary and secondary word-level stress)
     94 
     95 ----
     96 3. PROCESS_PHR: then, after processing these WORDPHON items,
     97 together with the trailing PUNC item results in:
     98 
     99 -> BOUND(BOUNDstrength,BOUNDtype)
    100 
    101 being added in the sequence of WORDPHON (respectively inserted instead
    102 of the PUNC). All PUNC, incl PUNC(...FLUSH...) now gone.
    103 
    104 ----
    105 4. PROCESS_ACC: then, after processing the WORDPHON and BOUND items
    106 results in:
    107 
    108 -> WORDPHON(POS,ACC)phon
    109 
    110 A postprocessing step of accentuation is hard-coded in the
    111 accentuation module: In case the whole word does not have any stress
    112 at all (primary or secondary or both) then do the following mapping:
    113 
    114   ACC0 nostress -> ACC0
    115   ACC1 nostress -> ACC3
    116   ACC2 nostress -> ACC3
    117   ACC3 nostress -> ACC3
    118 
    119 ----
    120 - POS
    121   a single, unambiguous POS
    122 
    123 cf. picodata.h for
    124 - ACC    (sentence-level accent (aka prominence)) %d
    125   PICODATA_ACC0
    126   PICODATA_ACC1
    127   PICODATA_ACC2  (<- maybe mapped to ACC1, ie. no ACC2 in output)
    128   PICODATA_ACC3
    129 
    130 - BOUNDstrength %d
    131   PICODATA_ITEMINFO1_BOUND_SBEG (at sentence start)
    132   PICODATA_ITEMINFO1_BOUND_SEND (at sentence end)
    133   PICODATA_ITEMINFO1_BOUND_TERM (replaces a flush)
    134   PICODATA_ITEMINFO1_BOUND_PHR1 (primary boundary)
    135   PICODATA_ITEMINFO1_BOUND_PHR2 (short break)
    136   PICODATA_ITEMINFO1_BOUND_PHR3 (secondary phrase boundary, no break)
    137   PICODATA_ITEMINFO1_BOUND_PHR0 (no break, not produced by sa, not existing
    138           BOUND in item sequence equals PHR0 bound strength)
    139 
    140 - BOUNDtype    (created in sa base on punctuation, indicates type of phrase
    141                 following the boundary) %d
    142   PICODATA_ITEMINFO2_BOUNDTYPE_P
    143   PICODATA_ITEMINFO2_BOUNDTYPE_T
    144   PICODATA_ITEMINFO2_BOUNDTYPE_Q
    145   PICODATA_ITEMINFO2_BOUNDTYPE_E
    146 
    147 
    148 output sequence (without CMDs):
    149 
    150 <output> = { BOUND(BOUND_SBEG,PHRASEtype) <sentence> BOUND(BOUND_SEND,..)} BOUND(BOUND_TERM,..)
    151 
    152 
    153 <sentence> =   <phrase> { BOUND(BOUND_PHR1|2|3,BOUNDtype) <phrase> }
    154 
    155 <phrase> = WORDPHON(POS,ACC)phon { WORDPHON(POS,ACC)phon }
    156 
    157 
    158 Done in later PU: mapping ACC & word-level stress to syllable accent value
    159   ACC0 prim -> 0
    160   ACC1 prim -> 1
    161   ACC2 prim -> 2
    162   ACC3 prim -> 3
    163   ACC0 sec  -> 0
    164   ACC1 sec  -> 4
    165   ACC2 sec  -> 4
    166   ACC3 sec  -> 4
    167 
    168 
    169 other limitations
    170 =================
    171 
    172 - item size: header plus len=256 (valid for Pico in general)
    173 - see defines below for max nr of items. Item heads plus ref. to contents
    174   buffer are stored in array with fixed size elements. Two restrictions:
    175   - MAXNR_HEADX (max nr elements==items in headx array)
    176   - CONTENTSSIZE (max size of all contents together
    177  */
    178 
    179 
    180 #ifndef PICOSA_H_
    181 #define PICOSA_H_
    182 
    183 #include "picoos.h"
    184 #include "picodata.h"
    185 #include "picorsrc.h"
    186 
    187 #ifdef __cplusplus
    188 extern "C" {
    189 #endif
    190 #if 0
    191 }
    192 #endif
    193 
    194 
    195 /* nr item restriction: maximum number of extended item heads in headx */
    196 #define PICOSA_MAXNR_HEADX    60
    197 /* nr item restriction: maximum size of all item contents together in cont */
    198 #define PICOSA_MAXSIZE_CBUF 7680
    199 
    200 /* maximum length of an item incl. head for input GetItem buffer */
    201 #define PICOSA_MAXITEMSIZE   260
    202 
    203 
    204 picodata_ProcessingUnit picosa_newSentAnaUnit(
    205         picoos_MemoryManager mm,
    206     picoos_Common common,
    207         picodata_CharBuffer cbIn,
    208         picodata_CharBuffer cbOut,
    209         picorsrc_Voice voice);
    210 
    211 #ifdef __cplusplus
    212 }
    213 #endif
    214 
    215 
    216 #endif /*PICOSA_H_*/
    217