Lines Matching refs:sa
61 * shortcut : sa
246 sa_subobj_t * sa;
259 sa = (sa_subobj_t *) this->subObj;
261 /* sa->common = this->common; */
263 sa->procState = SA_STEPSTATE_COLLECT;
265 sa->inspaceok = TRUE;
266 sa->needsmoreitems = TRUE;
268 sa->headxBottom = 0;
269 sa->headxLen = 0;
270 sa->cbuf1BufSize = PICOSA_MAXSIZE_CBUF;
271 sa->cbuf2BufSize = PICOSA_MAXSIZE_CBUF;
272 sa->cbuf1Len = 0;
273 sa->cbuf2Len = 0;
277 sa->headx[i].head.type = 0;
278 sa->headx[i].head.info1 = PICODATA_ITEMINFO1_NA;
279 sa->headx[i].head.info2 = PICODATA_ITEMINFO2_NA;
280 sa->headx[i].head.len = 0;
281 sa->headx[i].cind = 0;
284 sa->cbuf1[i] = 0;
285 sa->cbuf2[i] = 0;
290 sa->phonesTransduced = FALSE;
291 sa->phonBuf = sa->phonBufA;
292 sa->phonBufOut = sa->phonBufB;
293 sa->phonReadPos = 0;
294 sa->phonWritePos = 0;
295 sa->nextReadPos = 0;
303 sa->numFsts = 0;
307 sa->fst[sa->numFsts++] = fst;
310 sa->curFst = 0;
311 PICODBG_DEBUG(("got %i fsts", sa->numFsts));
313 sa->fixedIds = picoktab_getFixedIds(this->voice->kbArray[PICOKNOW_KBID_FIXED_IDS]);
316 sa->tabgraphs =
318 if (sa->tabgraphs == NULL) {
325 sa->tabphones =
327 if (sa->tabphones == NULL) {
337 if (picoktab_hasVowelProp(sa->tabphones, itmp)) {
340 if (picoktab_hasDiphthProp(sa->tabphones, itmp)) {
343 if (picoktab_hasGlottProp(sa->tabphones, itmp)) {
346 if (picoktab_hasNonsyllvowelProp(sa->tabphones, itmp)) {
349 if (picoktab_hasSyllconsProp(sa->tabphones, itmp)) {
352 if (picoktab_isPrimstress(sa->tabphones, itmp)) {
355 if (picoktab_isSecstress(sa->tabphones, itmp)) {
358 if (picoktab_isSyllbound(sa->tabphones, itmp)) {
361 if (picoktab_isPause(sa->tabphones, itmp)) {
367 picoktab_getPrimstressID(sa->tabphones)));
369 picoktab_getSecstressID(sa->tabphones)));
371 picoktab_getSyllboundID(sa->tabphones)));
373 picoktab_getPauseID(sa->tabphones)));
378 sa->tabpos =
380 if (sa->tabpos == NULL) {
387 sa->dtposd = picokdt_getDtPosD(this->voice->kbArray[PICOKNOW_KBID_DT_POSD]);
388 if (sa->dtposd == NULL) {
395 sa->dtg2p = picokdt_getDtG2P(this->voice->kbArray[PICOKNOW_KBID_DT_G2P]);
396 if (sa->dtg2p == NULL) {
403 sa->lex = picoklex_getLex(this->voice->kbArray[PICOKNOW_KBID_LEX_MAIN]);
404 if (sa->lex == NULL) {
411 sa->numUlex = 0;
415 sa->ulex[sa->numUlex++] = ulex;
418 PICODBG_DEBUG(("got %i user lexica", sa->numUlex));
433 sa_subobj_t * sa;
435 sa = (sa_subobj_t *) this->subObj;
436 picotrns_deallocate_alt_desc_buf(mm,&sa->altDescBuf);
449 sa_subobj_t * sa;
468 sa = (sa_subobj_t *) this->subObj;
470 sa->altDescBuf = picotrns_allocate_alt_desc_buf(mm, SA_MAX_ALTDESC_SIZE, &sa->maxAltDescLen);
471 if (NULL == sa->altDescBuf) {
472 picotrns_deallocate_alt_desc_buf(mm,&sa->altDescBuf);
473 picoos_deallocate(mm, (void *)&sa);
490 register sa_subobj_t *sa,
499 if ((sa->headx[i].head.type == PICODATA_ITEM_WORDGRAPH) ||
500 (sa->headx[i].head.type == PICODATA_ITEM_WORDINDEX) ||
501 (sa->headx[i].head.type == PICODATA_ITEM_WORDPHON) ) {
502 val = sa->headx[i].head.info1;
512 register sa_subobj_t *sa) {
532 while ((first < sa->headxLen) &&
533 (sa->headx[first].head.type != PICODATA_ITEM_WORDGRAPH) &&
534 (sa->headx[first].head.type != PICODATA_ITEM_WORDINDEX) &&
535 (sa->headx[first].head.type != PICODATA_ITEM_WORDPHON)) {
538 if (first >= sa->headxLen) {
550 valbuf[half_nratt_posd+1] = sa->headx[first].head.info1;
553 valbuf[i] = saPosDItemSeqGetPosRight(this, sa, lastprev3, sa->headxLen, &lastprev3);
556 PICODBG_TRACE(("headxLen: %d", sa->headxLen));
559 for (ci = first; ci < sa->headxLen; ci++) {
562 PICODBG_TRACE(("iter: %d, type: %c", ci, sa->headx[ci].head.type));
565 if ((sa->headx[ci].head.type != PICODATA_ITEM_WORDGRAPH) &&
566 (sa->headx[ci].head.type != PICODATA_ITEM_WORDINDEX) &&
567 (sa->headx[ci].head.type != PICODATA_ITEM_WORDPHON)) {
571 PICODBG_TRACE(("iter: %d, curPOS: %d", ci, sa->headx[ci].head.info1));
586 valbuf[PICOKDT_NRATT_POSD-1] = saPosDItemSeqGetPosRight(this, sa, lastprev3, sa->headxLen, &lastprev3);
589 if (sa->headx[ci].head.info1 != valbuf[half_nratt_posd]) {
593 valbuf[half_nratt_posd] = sa->headx[ci].head.info1;
599 if (picoktab_isUniquePos(sa->tabpos, (picoos_uint8) curPOS)) {
603 if (!picokdt_dtPosDreverseMapOutFixed(sa->dtposd, curPOS,
613 PICODBG_DEBUG(("keeping: %d", sa->headx[ci].head.info1));
624 if (!picokdt_dtPosDconstructInVec(sa->dtposd, valbuf)) {
632 if (okay && (!picokdt_dtPosDclassify(sa->dtposd, &prevout))) {
640 if (okay && (!picokdt_dtPosDdecomposeOutClass(sa->dtposd, &dtres))) {
659 sa->headx[ci].head.info1 = (picoos_uint8)dtres.class;
660 if (sa->headx[ci].head.type == PICODATA_ITEM_WORDINDEX) {
666 for (i = 0; i < sa->headx[ci].head.len; i += PICOKLEX_POSIND_SIZE) {
668 if (picoktab_isPartOfPosGroup(sa->tabpos,
670 sa->cbuf1[sa->headx[ci].cind + i])) {
673 sa->headx[ci].cind += i;
685 sa->headx[ci].head.len = PICOKLEX_POSIND_SIZE;
699 register sa_subobj_t *sa,
705 cind1 = sa->headx[ind].cind;
706 sa->headx[ind].cind = sa->cbuf2Len;
709 if (sa->headx[ind].head.len > (sa->cbuf2BufSize - sa->cbuf2Len)) {
710 sa->headx[ind].head.len = sa->cbuf2BufSize - sa->cbuf2Len;
714 if (sa->headx[ind].head.len == 0) {
715 sa->headx[ind].cind = 0;
719 for (i = 0; i < sa->headx[ind].head.len; i++) {
720 sa->cbuf2[sa->cbuf2Len] = sa->cbuf1[cind1 + i];
721 sa->cbuf2Len++;
725 sa->headx[ind].head.type, sa->headx[ind].head.len));
734 register sa_subobj_t *sa,
742 if (picoklex_lexIndLookup(lex, &(sa->cbuf1[sa->headx[ind].cind + 1]),
744 sa->headx[ind].cind = sa->cbuf2Len;
747 if (plen > (sa->cbuf2BufSize - sa->cbuf2Len)) {
748 plen = sa->cbuf2BufSize - sa->cbuf2Len;
753 sa->headx[ind].cind = 0;
758 sa->headx[ind].head.type = PICODATA_ITEM_WORDPHON;
759 sa->headx[ind].head.len = plen;
762 sa->cbuf2[sa->cbuf2Len] = phones[i];
763 sa->cbuf2Len++;
792 register sa_subobj_t *sa,
808 !picoktab_hasVowellikeProp(sa->tabgraphs, cstr, PICOBASE_UTF8_MAXLEN)) {
816 if (picoktab_hasVowellikeProp(sa->tabgraphs, cstr,
830 register sa_subobj_t *sa,
854 /* use sa->tmpbuf[PICOSA_MAXITEMSIZE] to temporarly store the
890 if (!saGetNrVowel(this, sa, graph, graphlen, nCount-1, &nrvow,
898 if (!picokdt_dtG2PconstructInVec(sa->dtg2p,
918 if (okay && (!picokdt_dtG2Pclassify(sa->dtg2p, &nOutVal))) {
927 if (okay && (!picokdt_dtG2PdecomposeOutClass(sa->dtg2p, &dtresv))) {
952 sa->tmpbuf[phonesind--] = (picoos_uint8)dtresv.classvec[i];
954 if (picoktab_isPrimstress(sa->tabphones,
997 phones[i] = sa->tmpbuf[phonesind];
1006 register sa_subobj_t *sa,
1012 if (saDoG2P(this, sa, &(sa->cbuf1[sa->headx[ind].cind]),
1013 sa->headx[ind].head.len, sa->headx[ind].head.info1,
1014 &(sa->cbuf2[sa->cbuf2Len]), (sa->cbuf2BufSize - sa->cbuf2Len),
1025 sa->headx[ind].head.type = PICODATA_ITEM_WORDPHON;
1026 sa->headx[ind].head.len = (picoos_uint8)plen;
1027 sa->headx[ind].cind = sa->cbuf2Len;
1028 sa->cbuf2Len += plen;
1044 static pico_status_t saAddPhoneme(register sa_subobj_t *sa, picoos_uint16 pos, picoos_uint16 sym) {
1050 PICODBG_DEBUG(("adding %i/%i (%c on plane %i) at phonBuf[%i]",pos,sym,unshifted,plane,sa->phonWritePos));
1052 if (PICOTRNS_MAX_NUM_POSSYM <= sa->phonWritePos) {
1057 sa->phonBuf[sa->phonWritePos].pos = pos;
1058 sa->phonBuf[sa->phonWritePos].sym = sym;
1059 sa->phonWritePos++;
1065 static pico_status_t saAddStartPhoneme(register sa_subobj_t *sa) {
1066 return saAddPhoneme(sa, PICOTRNS_POS_IGNORE,
1067 (PICOKFST_PLANE_INTERN << 8) + sa->fixedIds->phonStartId);
1071 static pico_status_t saAddTermPhoneme(register sa_subobj_t *sa) {
1072 return saAddPhoneme(sa, PICOTRNS_POS_IGNORE,
1073 (PICOKFST_PLANE_INTERN << 8) + sa->fixedIds->phonTermId);
1079 register sa_subobj_t *sa, picoos_uint16 pos,
1096 sa->phonWritePos = 0;
1098 rv = saAddPhoneme(sa, PICOTRNS_POS_IGNORE,
1099 (PICOKFST_PLANE_INTERN << 8) + sa->fixedIds->phonStartId);
1104 rv = saAddPhoneme(sa, pos+PICODATA_ITEM_HEADSIZE+i, fstSymbol);
1106 rv = saAddPhoneme(sa, PICOTRNS_POS_IGNORE,
1107 (PICOKFST_PLANE_INTERN << 8) + sa->fixedIds->phonTermId);
1108 sa->nextReadPos = pos + PICODATA_ITEM_HEADSIZE + head->len;
1126 static pico_status_t getNextPosSym(sa_subobj_t * sa, picoos_int16 * pos, picoos_int16 * sym,
1129 while ((sa->phonReadPos < sa->phonWritePos) && (PICOTRNS_POS_IGNORE == sa->phonBuf[sa->phonReadPos].pos)) {
1130 PICODBG_DEBUG(("ignoring phone at sa->phonBuf[%i] because it has pos==IGNORE",sa->phonReadPos));
1131 sa->phonReadPos++;
1133 if ((sa->phonReadPos < sa->phonWritePos)) {
1134 *pos = sa->phonBuf[sa->phonReadPos].pos;
1136 *sym = sa->phonBuf[sa->phonReadPos++].sym;
1191 register sa_subobj_t *sa;
1203 sa = (sa_subobj_t *) this->subObj;
1208 sa->procState, sa->headxLen, sa->cbuf1Len,
1209 sa->cbuf2Len));
1211 switch (sa->procState) {
1219 while (sa->inspaceok && sa->needsmoreitems
1221 (rv = picodata_cbGetItem(this->cbIn, sa->tmpbuf,
1223 rvP = picodata_get_itemparts(sa->tmpbuf,
1225 &(sa->headx[sa->headxLen].head),
1226 &(sa->cbuf1[sa->cbuf1Len]),
1227 sa->cbuf1BufSize-sa->cbuf1Len,
1238 if ((sa->headx[sa->headxLen].head.type ==
1240 (sa->headx[sa->headxLen].head.info1 ==
1242 sa->headx[sa->headxLen].head.type =
1244 sa->headx[sa->headxLen].head.info1 =
1246 sa->headx[sa->headxLen].head.info2 =
1248 sa->headx[sa->headxLen].head.len = 0;
1253 sa->headx[sa->headxLen].cind = sa->cbuf1Len;
1255 if ((sa->headx[sa->headxLen].head.type ==
1257 (sa->headx[sa->headxLen].head.info1 ==
1259 (sa->headx[sa->headxLen].head.info2 ==
1262 picoos_uint8 wordsep = picoktab_getWordboundID(sa->tabphones);
1264 sa->headx[sa->headxLen].head.type = PICODATA_ITEM_WORDPHON;
1265 sa->headx[sa
1266 sa->headx[sa->headxLen].head.info2 = PICODATA_ITEMINFO2_NA;
1269 while ((i < sa->headx[sa->headxLen].head.len) && (wordsep != sa->cbuf1[sa->headx[sa->headxLen].cind+i])) {
1270 PICODBG_INFO(("accepting phoneme %i",sa->cbuf1[sa->headx[sa->headxLen].cind+i]));
1274 if (i < sa->headx[sa->headxLen].head.len) {
1276 sa->headx[sa->headxLen].head.len = i;
1281 if (sa->headx[sa->headxLen].head.type ==
1283 sa->needsmoreitems = FALSE;
1287 if ((sa->headxLen >= (PICOSA_MAXNR_HEADX - 2)) ||
1288 ((sa->cbuf1BufSize - sa->cbuf1Len) <
1290 sa->inspaceok = FALSE;
1294 sa->headx[sa->headxLen].cind = sa->cbuf1Len;
1295 sa->cbuf1Len += clen;
1297 sa->headx[sa->headxLen].cind = 0;
1299 sa->headxLen++;
1302 if (!sa->needsmoreitems) {
1304 sa->procState = SA_STEPSTATE_PROCESS_POSD;
1306 } else if (!sa->inspaceok) {
1310 sa->headx[sa->headxLen].head.type = PICODATA_ITEM_PUNC;
1311 sa->headx[sa->headxLen].head.info1 =
1313 sa->headx[sa->headxLen].head.info2 =
1315 sa->headx[sa->headxLen].head.len = 0;
1316 sa->needsmoreitems = FALSE; /* not really needed for now */
1317 sa->headxLen++;
1322 sa->procState = SA_STEPSTATE_PROCESS_POSD;
1349 if (sa->headxLen > 0) {
1352 if (PICO_OK != saDisambPos(this, sa)) {
1357 sa->procState = SA_STEPSTATE_PROCESS_WPHO;
1359 } else if (sa->headxLen == 0) { /* no items in inBuf */
1361 sa->procState = SA_STEPSTATE_COLLECT;
1368 for (i = 0; i < sa->headxLen; i++) {
1369 ittype = sa->headx[i].head.type;
1371 PICODBG_INFO_MSG(("sa-d: ("));
1373 if ((32 <= sa->headx[i].head.info1) &&
1374 (sa->headx[i].head.info1 < 127) &&
1377 PICODBG_INFO_MSG(("'%c',",sa->headx[i].head.info1));
1379 PICODBG_INFO_MSG(("%3d,", sa->headx[i].head.info1));
1381 if ((32 <= sa->headx[i].head.info2) &&
1382 (sa->headx[i].head.info2 < 127)) {
1383 PICODBG_INFO_MSG(("'%c',",sa->headx[i].head.info2));
1385 PICODBG_INFO_MSG(("%3d,", sa->headx[i].head.info2));
1387 PICODBG_INFO_MSG(("%3d)", sa->headx[i].head.len));
1389 for (j = 0; j < sa->headx[i].head.len; j++) {
1393 sa->cbuf1[sa->headx[i].cind+j]));
1396 sa->cbuf1[sa->headx[i].cind+j]));
1413 if (sa->headxLen > 0) {
1418 if (sa->cbuf2Len > 0) {
1428 for (i = 0; i < sa->headxLen; i++) {
1429 switch (sa->headx[i].head.type) {
1431 if (PICO_OK != saGraphemeToPhoneme(this, sa,
1441 if (0 == sa->headx[i].head.info2) {
1442 lex = sa->lex;
1444 lex = sa->ulex[sa->headx[i].head.info2-1];
1446 if (PICO_OK != saLexIndLookup(this, sa, lex, i)) {
1457 if (PICO_OK != saCopyItemContent1to2(this, sa,
1469 sa->cbuf1Len = 0;
1470 sa->procState = SA_STEPSTATE_PROCESS_TRNS_PARSE;
1472 } else if (sa->headxLen == 0) { /* no items in inBuf */
1474 sa->procState = SA_STEPSTATE_COLLECT;
1481 for (i = 0; i < sa->headxLen; i++) {
1482 ittype = sa->headx[i].head.type;
1484 PICODBG_INFO_MSG(("sa-g: ("));
1486 if ((32 <= sa->headx[i].head.info1) &&
1487 (sa->headx[i].head.info1 < 127) &&
1489 PICODBG_INFO_MSG(("'%c',",sa->headx[i].head.info1));
1491 PICODBG_INFO_MSG(("%3d,", sa->headx[i].head.info1));
1493 if ((32 <= sa->headx[i].head.info2) &&
1494 (sa->headx[i].head.info2 < 127)) {
1495 PICODBG_INFO_MSG(("'%c',",sa->headx[i].head.info2));
1497 PICODBG_INFO_MSG(("%3d,", sa->headx[i].head.info2));
1499 PICODBG_INFO_MSG(("%3d)", sa->headx[i].head.len));
1501 for (j = 0; j < sa->headx[i].head.len; j++) {
1504 sa->cbuf2[sa->headx[i].cind+j]));
1507 sa->cbuf2[sa->headx[i].cind+j]));
1523 sa->headxBottom, sa->headxLen));
1526 if (0 == sa->headxLen) {
1528 sa->headxBottom = 0;
1529 sa->cbuf2Len = 0;
1531 sa->inspaceok = TRUE;
1532 sa->needsmoreitems = TRUE;
1534 sa->procState = SA_STEPSTATE_COLLECT;
1538 sa->procState = SA_STEPSTATE_FEED;
1541 &(sa->headx[sa->headxBottom].head),
1542 &(sa->cbuf2[sa->headx[sa->headxBottom].cind]),
1543 sa->headx[sa->headxBottom].head.len, sa->tmpbuf,
1546 if (PICODATA_ITEM_WORDPHON == sa->headx[sa->headxBottom].head.type) {
1548 rv = saExtractPhonemes(this, sa, 0, &(sa->headx[sa->headxBottom].head),
1549 &(sa->cbuf2[sa->headx[sa->headxBottom].cind]));
1552 sa->procState = SA_STEPSTATE_PROCESS_TRNS_FST;
1559 if (SA_STEPSTATE_FEED == sa->procState) {
1561 (picoos_uint8 *)"sa-p: ",
1562 sa->tmpbuf, PICOSA_MAXITEMSIZE);
1567 sa->headxBottom++;
1568 sa->headxLen--;
1581 if (0 == sa->numFsts) {
1582 PICODBG_DEBUG(("doing trivial sylabification with %i phones", sa->phonWritePos));
1586 PICODBG_INFO_MSG(("sa trying to trivially syllabify: "));
1587 PICOTRNS_PRINTSYMSEQ(this->voice->kbArray[PICOKNOW_KBID_DBG], sa->phonBuf, sa->phonWritePos);
1592 picotrns_trivial_syllabify(sa->tabphones, sa->phonBuf,
1593 sa->phonWritePos, sa->phonBufOut,
1594 &sa->phonWritePos,PICOTRNS_MAX_NUM_POSSYM);
1595 PICODBG_DEBUG(("returned from trivial sylabification with %i phones", sa->phonWritePos));
1599 PICODBG_INFO_MSG(("sa returned from syllabification: "));
1600 sa->phonBufOut, sa->phonWritePos);
1606 PICODBG_DEBUG(("doing epsilon elimination with %i phones", sa->phonWritePos));
1607 picotrns_eliminate_epsilons(sa->phonBufOut,
1608 sa->phonWritePos, sa->phonBuf,
1609 &sa->phonWritePos,PICOTRNS_MAX_NUM_POSSYM);
1610 PICODBG_DEBUG(("returning from epsilon elimination with %i phones", sa->phonWritePos));
1611 sa->phonReadPos = 0;
1612 sa->phonesTransduced = 1;
1613 sa->procState = SA_STEPSTATE_FEED;
1619 if (sa->curFst >= sa->numFsts) {
1621 sa->curFst = 0;
1622 sa->phonReadPos = 0;
1623 sa->phonesTransduced = 1;
1624 sa->procState = SA_STEPSTATE_FEED;
1635 PICODBG_INFO_MSG(("sa trying to transduce: "));
1636 PICOTRNS_PRINTSYMSEQ(this->voice->kbArray[PICOKNOW_KBID_DBG], sa->phonBuf, sa->phonWritePos);
1640 picotrns_transduce(sa->fst[sa->curFst], FALSE,
1641 picotrns_printSolution, sa->phonBuf, sa->phonWritePos, sa->phonBufOut,
1642 &sa->phonWritePos,
1643 PICOTRNS_MAX_NUM_POSSYM, sa->altDescBuf,
1644 sa->maxAltDescLen, &nrSteps);
1648 PICODBG_INFO_MSG(("sa returned from transduction: "));
1649 PICOTRNS_PRINTSYMSEQ(this->voice->kbArray[PICOKNOW_KBID_DBG], sa->phonBufOut, sa->phonWritePos);
1662 picotrns_eliminate_epsilons(sa->phonBufOut,
1663 sa->phonWritePos, sa->phonBuf, &sa->phonWritePos,PICOTRNS_MAX_NUM_POSSYM);
1664 sa->phonesTransduced = 1;
1666 sa->curFst++;
1678 if (sa->phonesTransduced) {
1683 while (SA_POSSYM_OK == (rv = getNextPosSym(sa,&pos,&sym,sa->nextReadPos))) {
1687 sa->tmpbuf[phonWritePos++] = (picoos_uint8) sym;
1690 picodata_set_itemlen(sa->tmpbuf,PICODATA_ITEM_HEADSIZE,phonWritePos - PICODATA_ITEM_HEADSIZE);
1695 sa->phonesTransduced = 0;
1697 } /* if (sa->phonesTransduced) */
1700 rvP = picodata_cbPutItem(this->cbOut, sa->tmpbuf,
1720 sa->tmpbuf, PICOSA_MAXITEMSIZE);
1722 sa->procState = SA_STEPSTATE_PROCESS_TRNS_PARSE;