@@ -30,14 +30,14 @@ EXPORT Result PhonologyEngineNormalizeText(char * szText, NormalizedTextHandle *
3030 char *pos = szNormalizedText;
3131 char sakinys[200 ];
3232 char * pPhrases[1024 ];
33+ int * pPhraseLetterMap[1024 ];
3334 int n, phraseCount = 0 ;
3435
3536 while ((pos != (void *)1 ))
3637 {
3738 int hr2 = 0 ;
3839 int lp = (int )(pos - szNormalizedText);
3940 n = sscanf (pos, " %[^\n ]" , sakinys);
40- pos = strchr (pos, ' \n ' ) + 1 ;
4141 if (n < 0 )
4242 break ;
4343 if (n == 0 )
@@ -48,17 +48,23 @@ EXPORT Result PhonologyEngineNormalizeText(char * szText, NormalizedTextHandle *
4848 sakinys[0 ] = 0 ; // jei eilute tuscia arba tik neskaitytini simboliai
4949
5050 pPhrases[phraseCount] = (char *) malloc ((strlen (sakinys) + 1 ) * sizeof (char ));
51- if (!pPhrases[phraseCount]) return -3 ;
51+ pPhraseLetterMap[phraseCount] = (int *) malloc ((strlen (sakinys)) * sizeof (int ));
52+ if (!pPhrases[phraseCount] || !pPhraseLetterMap[phraseCount]) return -3 ;
5253 strcpy (pPhrases[phraseCount], sakinys);
54+ memcpy (pPhraseLetterMap[phraseCount], pArLetterPosistion + lp, strlen (sakinys) * sizeof (int ));
55+
56+ pos = strchr (pos, ' \n ' ) + 1 ;
5357 phraseCount++;
5458 }
5559
5660 pNormalizedText->phraseCount = phraseCount;
5761 pNormalizedText->pSzPhrases = (char **) malloc (sizeof (char *) * phraseCount);
62+ pNormalizedText->pArLetterMap = (int **) malloc (sizeof (int *) * phraseCount);
5863
59- if (!pNormalizedText->pSzPhrases ) return -4 ;
64+ if (!pNormalizedText->pSzPhrases || !pNormalizedText-> pArLetterMap ) return -4 ;
6065
6166 memcpy (pNormalizedText->pSzPhrases , pPhrases, sizeof (char *) * phraseCount);
67+ memcpy (pNormalizedText->pArLetterMap , pPhraseLetterMap, sizeof (int *) * phraseCount);
6268
6369 *pHandle = pNormalizedText;
6470
@@ -79,10 +85,12 @@ EXPORT Result PhonologyEngineNormalizedTextFree(NormalizedTextHandle * pHandle)
7985 for (int i = 0 ; i < pNormalizedText->phraseCount ; i++)
8086 {
8187 free (pNormalizedText->pSzPhrases [i]);
88+ free (pNormalizedText->pArLetterMap [i]);
8289 }
8390 }
8491
8592 free (pNormalizedText->pSzPhrases );
93+ free (pNormalizedText->pArLetterMap );
8694 free (pNormalizedText);
8795 *pHandle = NULL ;
8896
@@ -117,6 +125,24 @@ EXPORT Result PhonologyEngineNormalizedTextGetPhrase(NormalizedTextHandle handle
117125 return 0 ;
118126}
119127
128+ EXPORT Result PhonologyEngineNormalizedTextGetPhraseLetterMap (NormalizedTextHandle handle, int index, int ** pArValue, int * pCount)
129+ {
130+ NormalizedText * pOutput = GetObjectPtr (NormalizedText, handle);
131+
132+ if (!handle) return -1 ;
133+ if (!pArValue) return -2 ;
134+ if (!pCount) return -3 ;
135+
136+ int count = 0 ;
137+
138+ if (index < 0 || index >= pOutput->phraseCount ) return -4 ;
139+
140+ *pArValue = pOutput->pArLetterMap [index];
141+ *pCount = strlen (pOutput->pSzPhrases [index]);
142+
143+ return 0 ;
144+ }
145+
120146// //////////Pagrindine sintezavimo funkcija////////////////////////////////////////////////////////////////////////////////
121147EXPORT Result PhonologyEngineProcessPhrase (char * szNormalizedText, PhonologyEngineOutputHandle * pHandle)
122148{
0 commit comments