/* file ttpj1.c                                                       */
/* function ttpj1(st,sp,perr) for converting Japanese text to phones  */
/* Uses character functions defined in letfcns1.c                     */

#if !defined(COMPILE_ENVIRONMENT)
#include <gp/stdcenvf.h> /* std compile environment for functions */
#endif


  /*********************************************/
  /*  char *ttpj1(st,sp,perr)                  */
  /*  Converts text to phones                  */
  /*  Input: *st is a text string;             */
  /*  Output: *sp is a phone string;           */
  /*   (Returns sp.)                           */
  /*  Process: elementary.                     */
  /*  On return, *perr > 0 iff error.          */
  /*********************************************/
  char *ttpj1(char *st, char *sp, int *perr)
   {char *proc = "ttpj1";
    char *p,*q;
/* code */
 db_enter_msg(proc,1); /* debug only */
if (db_level > 1) printf("*DB: st=[%s]\n",st);
    *perr = 0;
/* convert letter to phone */
    q = sp;
    for (p = st; *p != '\0'; p++)
      {*q++ = ' ';       
       if (isvowel2(*p))
         {*q++ = *p;
          if ((*(p+1) == ':') ||
              ((*p == 'e')&&(*(p+1) == 'i')) ||
              ((*p == 'i')&&(*(p+1) == 'i')) )
            {*q++ = ':'; p++;
         }  }
       if (iscons2(*p))
         {if ((*p == 'g') && (!bound(*(p-1)))) {*q++ = 'n'; continue;}
          if ((*p == 'n') && (*(p+1) == '\''))
            {*q++ = 'e'; *q++ = 'n'; p++; continue;}
          if (*p == 'j') {*q++ = 'j'; *q++ = 'h'; continue;}
          if (*p == 'h') {*q++ = 'h'; *q++ = 'h'; continue;}
          if ((*p == 'c') && (*(p+1) == 'h'))
            {*q++ = 'c'; *q++ = 'h'; p++; continue;}
          if ((*p == 's') && (*(p+1) == 'h'))
            {*q++ = 's'; *q++ = 'h'; p++; continue;}
          if ((*p == 't') && (*(p+1) == 's'))
            {*q++ = 't'; *q++ = 's'; p++; continue;}
          *q++ = *p;
         }
      }
    *q = '\0';
 db_leave_msg(proc,1); /* debug only */
    return sp;
   }
/* end file ttpj1.c */
