/* Flite_Text_Analyzer_get_stress: get stress */
int Flite_Text_Analyzer_get_stress(Flite_Text_Analyzer * analyzer, int phoneme_index)
{
   Flite_Utterance *fu;

   if (analyzer == NULL || analyzer->pointer == NULL)
      return 0;
   fu = (Flite_Utterance *) analyzer->pointer;
   if (phoneme_index < 0 || phoneme_index >= fu->nitem)
      return 0;
   return ffeature_int(fu->items[phoneme_index], "R:SylStructure.parent.R:Syllable.stress");
}
/* Flite_Text_Analyzer_get_nphrase_in_utterance: get number of phrases in utterance */
int Flite_Text_Analyzer_get_nphrase_in_utterance(Flite_Text_Analyzer * analyzer, int phoneme_index)
{
   Flite_Utterance *fu;

   if (analyzer == NULL || analyzer->pointer == NULL)
      return 0;
   fu = (Flite_Utterance *) analyzer->pointer;
   if (phoneme_index < 0 || phoneme_index >= fu->nitem)
      return 0;
   return ffeature_int(fu->items[phoneme_index], "R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_phrases");
}
/* Flite_HTS_Engine_create_label: create label per phoneme */
static void Flite_HTS_Engine_create_label(Flite_HTS_Engine * f, cst_item * item, char *label)
{
   const char *p1 = ffeature_string(item, "p.p.name");
   const char *p2 = ffeature_string(item, "p.name");
   const char *p3 = ffeature_string(item, "name");
   const char *p4 = ffeature_string(item, "n.name");
   const char *p5 = ffeature_string(item, "n.n.name");

   if (strcmp(p3, "pau") == 0) {
      /* for pause */
      int a3 = ffeature_int(item, "p.R:SylStructure.parent.R:Syllable.syl_numphones");
      int c3 = ffeature_int(item, "n.R:SylStructure.parent.R:Syllable.syl_numphones");
      int d2 = ffeature_int(item, "p.R:SylStructure.parent.parent.R:Word.word_numsyls");
      int f2 = ffeature_int(item, "n.R:SylStructure.parent.parent.R:Word.word_numsyls");
      int g1 = ffeature_int(item, "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_syls_in_phrase");
      int g2 = ffeature_int(item, "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_words_in_phrase");
      int i1 = ffeature_int(item, "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_syls_in_phrase");
      int i2 = ffeature_int(item, "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_words_in_phrase");
      int j1, j2, j3;
      if (item_next(item) != NULL) {
         j1 = ffeature_int(item, "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_syls");
         j2 = ffeature_int(item, "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_words");
         j3 = ffeature_int(item, "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_phrases");
      } else {
         j1 = ffeature_int(item, "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_syls");
         j2 = ffeature_int(item, "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_words");
         j3 = ffeature_int(item, "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_phrases");
      }
      sprintf(label, "%s^%s-%s+%s=%s@x_x/A:%s_%s_%s/B:x-x-x@x-x&x-x#x-x$x-x!x-x;x-x|x/C:%s+%s+%s/D:%s_%s/E:x+x@x+x&x+x#x+x/F:%s_%s/G:%s_%s/H:x=x^x=x|x/I:%s=%s/J:%d+%d-%d",     /* */
              strcmp(p1, "0") == 0 ? "x" : p1,  /* p1 */
              strcmp(p2, "0") == 0 ? "x" : p2,  /* p2 */
              p3,               /* p3 */
              strcmp(p4, "0") == 0 ? "x" : p4,  /* p4 */
              strcmp(p5, "0") == 0 ? "x" : p5,  /* p5 */
              a3 == 0 ? "x" : ffeature_string(item, "p.R:SylStructure.parent.R:Syllable.stress"),       /* a1 */
              a3 == 0 ? "x" : ffeature_string(item, "p.R:SylStructure.parent.R:Syllable.accented"),     /* a2 */
              a3 == 0 ? "x" : val_string(val_string_n(a3)),     /* a3 */
              c3 == 0 ? "x" : ffeature_string(item, "n.R:SylStructure.parent.R:Syllable.stress"),       /* c1 */
              c3 == 0 ? "x" : ffeature_string(item, "n.R:SylStructure.parent.R:Syllable.accented"),     /* c2 */
              c3 == 0 ? "x" : val_string(val_string_n(c3)),     /* c3 */
              d2 == 0 ? "x" : ffeature_string(item, "p.R:SylStructure.parent.parent.R:Word.gpos"),      /* d1 */
              d2 == 0 ? "x" : val_string(val_string_n(d2)),     /* d2 */
              f2 == 0 ? "x" : ffeature_string(item, "n.R:SylStructure.parent.parent.R:Word.gpos"),      /* f1 */
              f2 == 0 ? "x" : val_string(val_string_n(f2)),     /* f2 */
              g1 == 0 ? "x" : val_string(val_string_n(g1)),     /* g1 */
              g2 == 0 ? "x" : val_string(val_string_n(g2)),     /* g2 */
              i1 == 0 ? "x" : val_string(val_string_n(i1)),     /* i1 */
              i2 == 0 ? "x" : val_string(val_string_n(i2)),     /* i2 */
              j1,               /* j1 */
              j2,               /* j2 */
              j3);              /* j3 */
   } else {
      /* for no pause */
      int p6 = ffeature_int(item, "R:SylStructure.pos_in_syl") + 1;
      int a3 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.p.syl_numphones");
      int b3 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.syl_numphones");
      int b4 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.pos_in_word") + 1;
      int b12 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.lisp_distance_to_p_stress");
      int b13 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.lisp_distance_to_n_stress");
      int b14 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.lisp_distance_to_p_accent");
      int b15 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.lisp_distance_to_n_accent");
      int c3 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.n.syl_numphones");
      int d2 = ffeature_int(item, "R:SylStructure.parent.parent.R:Word.p.word_numsyls");
      int e2 = ffeature_int(item, "R:SylStructure.parent.parent.R:Word.word_numsyls");
      int e3 = ffeature_int(item, "R:SylStructure.parent.parent.R:Word.pos_in_phrase") + 1;
      int e7 = ffeature_int(item, "R:SylStructure.parent.parent.R:Word.lisp_distance_to_p_content");
      int e8 = ffeature_int(item, "R:SylStructure.parent.parent.R:Word.lisp_distance_to_n_content");
      int f2 = ffeature_int(item, "R:SylStructure.parent.parent.R:Word.n.word_numsyls");
      int g1 = ffeature_int(item, "R:SylStructure.parent.parent.R:Phrase.parent.p.lisp_num_syls_in_phrase");
      int g2 = ffeature_int(item, "R:SylStructure.parent.parent.R:Phrase.parent.p.lisp_num_words_in_phrase");
      int h2 = ffeature_int(item, "R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_words_in_phrase");
      int h3 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.sub_phrases") + 1;
      const char *h5 = ffeature_string(item, "R:SylStructure.parent.parent.R:Phrase.parent.daughtern.R:SylStructure.daughtern.endtone");
      int i1 = ffeature_int(item, "R:SylStructure.parent.parent.R:Phrase.parent.n.lisp_num_syls_in_phrase");
      int i2 = ffeature_int(item, "R:SylStructure.parent.parent.R:Phrase.parent.n.lisp_num_words_in_phrase");
      int j1 = ffeature_int(item, "R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_syls");
      int j2 = ffeature_int(item, "R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_words");
      int j3 = ffeature_int(item, "R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_phrases");
      sprintf(label, "%s^%s-%s+%s=%s@%d_%d/A:%s_%s_%s/B:%d-%d-%d@%d-%d&%d-%d#%d-%d$%d-%d!%s-%s;%s-%s|%s/C:%s+%s+%s/D:%s_%s/E:%s+%d@%d+%d&%d+%d#%s+%s/F:%s_%s/G:%s_%s/H:%d=%d^%d=%d|%s/I:%s=%s/J:%d+%d-%d",      /* */
              strcmp(p1, "0") == 0 ? "x" : p1,  /* p1 */
              strcmp(p2, "0") == 0 ? "x" : p2,  /* p2 */
              p3,               /* p3 */
              strcmp(p4, "0") == 0 ? "x" : p4,  /* p4 */
              strcmp(p5, "0") == 0 ? "x" : p5,  /* p5 */
              p6,               /* p6 */
              b3 - p6 + 1,      /* p7 */
              a3 == 0 ? "x" : ffeature_string(item, "R:SylStructure.parent.R:Syllable.p.stress"),       /* a1 */
              a3 == 0 ? "x" : ffeature_string(item, "R:SylStructure.parent.R:Syllable.p.accented"),     /* a2 */
              a3 == 0 ? "x" : val_string(val_string_n(a3)),     /* a3 */
              ffeature_int(item, "R:SylStructure.parent.R:Syllable.stress"),    /* b1 */
              ffeature_int(item, "R:SylStructure.parent.R:Syllable.accented"),  /* b2 */
              b3,               /* b3 */
              b4,               /* b4 */
              e2 - b4 + 1,      /* b5 */
              ffeature_int(item, "R:SylStructure.parent.R:Syllable.syl_in") + 1,        /* b6 */
              ffeature_int(item, "R:SylStructure.parent.R:Syllable.syl_out") + 1,       /* b7 */
              ffeature_int(item, "R:SylStructure.parent.R:Syllable.ssyl_in"),   /* b8 */
              ffeature_int(item, "R:SylStructure.parent.R:Syllable.ssyl_out"),  /* b9 */
              ffeature_int(item, "R:SylStructure.parent.R:Syllable.asyl_in"),   /* b10 */
              ffeature_int(item, "R:SylStructure.parent.R:Syllable.asyl_out"),  /* b11 */
              b12 == 0 ? "x" : val_string(val_string_n(b12)),   /* b12 */
              b13 == 0 ? "x" : val_string(val_string_n(b13)),   /* b13 */
              b14 == 0 ? "x" : val_string(val_string_n(b14)),   /* b14 */
              b15 == 0 ? "x" : val_string(val_string_n(b15)),   /* b15 */
              ffeature_string(item, "R:SylStructure.parent.R:Syllable.syl_vowel"),      /* b16 */
              c3 == 0 ? "x" : ffeature_string(item, "R:SylStructure.parent.R:Syllable.n.stress"),       /* c1 */
              c3 == 0 ? "x" : ffeature_string(item, "R:SylStructure.parent.R:Syllable.n.accented"),     /* c2 */
              c3 == 0 ? "x" : val_string(val_string_n(c3)),     /* c3 */
              d2 == 0 ? "x" : ffeature_string(item, "R:SylStructure.parent.parent.R:Word.p.gpos"),      /* d1 */
              d2 == 0 ? "x" : val_string(val_string_n(d2)),     /* d2 */
              ffeature_string(item, "R:SylStructure.parent.parent.R:Word.gpos"),        /* e1 */
              e2,               /* e2 */
              e3,               /* e3 */
              h2 - e3 + 1,      /* e4 */
              ffeature_int(item, "R:SylStructure.parent.parent.R:Word.content_words_in"),       /* e5 */
              ffeature_int(item, "R:SylStructure.parent.parent.R:Word.content_words_out"),      /* e6 */
              e7 == 0 ? "x" : val_string(val_string_n(e7)),     /* e7 */
              e8 == 0 ? "x" : val_string(val_string_n(e8)),     /* e8 */
              f2 == 0 ? "x" : ffeature_string(item, "R:SylStructure.parent.parent.R:Word.n.gpos"),      /* f1 */
              f2 == 0 ? "x" : val_string(val_string_n(f2)),     /* f2 */
              g1 == 0 ? "x" : val_string(val_string_n(g1)),     /* g1 */
              g2 == 0 ? "x" : val_string(val_string_n(g2)),     /* g2 */
              ffeature_int(item, "R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_syls_in_phrase"),       /* h1 */
              h2,               /* h2 */
              h3,               /* h3 */
              j3 - h3 + 1,      /* h4 */
              strcmp(h5, "0") == 0 ? "NONE" : h5,       /* h5 */
              i1 == 0 ? "x" : val_string(val_string_n(i1)),     /* i1 */
              i2 == 0 ? "x" : val_string(val_string_n(i2)),     /* i2 */
              j1,               /* j1 */
              j2,               /* j2 */
              j3);              /* j3 */
   }
}
Example #4
0
int flite_ffeature_int(const cst_item *item,const char *featpath)
{
    return ffeature_int(item,featpath);
}
static void Flite_HTS_Engine_create_label(Flite_HTS_Engine * f, cst_item * item,
        char *label)
{
    char seg_pp[8];
    char seg_p[8];
    char seg_c[8];
    char seg_n[8];
    char seg_nn[8];
    int sub_phrases = 0;
    int lisp_total_phrases = 0;
    int tmp1 = 0;
    int tmp2 = 0;
    int tmp3 = 0;
    int tmp4 = 0;

    /* load segments */
    strcpy(seg_pp, ffeature_string(item, "p.p.name"));
    strcpy(seg_p, ffeature_string(item, "p.name"));
    strcpy(seg_c, ffeature_string(item, "name"));
    strcpy(seg_n, ffeature_string(item, "n.name"));
    strcpy(seg_nn, ffeature_string(item, "n.n.name"));

    if (strcmp(seg_c, "pau") == 0) {
        /* for pause */
        if (item_next(item) != NULL) {
            sub_phrases =
                ffeature_int(item,
                             "n.R:SylStructure.parent.R:Syllable.sub_phrases");
            tmp1 =
                ffeature_int(item,
                             "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_syls");
            tmp2 =
                ffeature_int(item,
                             "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_words");
            lisp_total_phrases =
                ffeature_int(item,
                             "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_phrases");
        } else {
            sub_phrases =
                ffeature_int(item,
                             "p.R:SylStructure.parent.R:Syllable.sub_phrases");
            tmp1 =
                ffeature_int(item,
                             "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_syls");
            tmp2 =
                ffeature_int(item,
                             "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_words");
            lisp_total_phrases =
                ffeature_int(item,
                             "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_phrases");
        }
        sprintf(label,
                "%s^%s-%s+%s=%s@x_x/A:%d_%d_%d/B:x-x-x@x-x&x-x#x-x$x-x!x-x;x-x|x/C:%d+%d+%d/D:%s_%d/E:x+x@x+x&x+x#x+x/F:%s_%d/G:%d_%d/H:x=x@%d=%d|%s/I:%d=%d/J:%d+%d-%d",
                strcmp(seg_pp, "0") == 0 ? "x" : seg_pp,
                strcmp(seg_p, "0") == 0 ? "x" : seg_p,
                seg_c,
                strcmp(seg_n, "0") == 0 ? "x" : seg_n,
                strcmp(seg_nn, "0") == 0 ? "x" : seg_nn,
                ffeature_int(item, "p.R:SylStructure.parent.R:Syllable.stress"),
                ffeature_int(item, "p.R:SylStructure.parent.R:Syllable.accented"),
                ffeature_int(item,
                             "p.R:SylStructure.parent.R:Syllable.syl_numphones"),
                ffeature_int(item, "n.R:SylStructure.parent.R:Syllable.stress"),
                ffeature_int(item, "n.R:SylStructure.parent.R:Syllable.accented"),
                ffeature_int(item,
                             "n.R:SylStructure.parent.R:Syllable.syl_numphones"),
                ffeature_string(item,
                                "p.R:SylStructure.parent.parent.R:Word.gpos"),
                ffeature_int(item,
                             "p.R:SylStructure.parent.parent.R:Word.word_numsyls"),
                ffeature_string(item,
                                "n.R:SylStructure.parent.parent.R:Word.gpos"),
                ffeature_int(item,
                             "n.R:SylStructure.parent.parent.R:Word.word_numsyls"),
                ffeature_int(item,
                             "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_syls_in_phrase"),
                ffeature_int(item,
                             "p.R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_words_in_phrase"),
                sub_phrases + 1, lisp_total_phrases - sub_phrases,
                ffeature_string(item,
                                "R:SylStructure.parent.parent.R:Phrase.parent.daughtern.R:SylStructure.daughtern.endtone"),
                ffeature_int(item,
                             "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_syls_in_phrase"),
                ffeature_int(item,
                             "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_words_in_phrase"),
                tmp1, tmp2, lisp_total_phrases);
    } else {
        /* for no pause */
        tmp1 = ffeature_int(item, "R:SylStructure.pos_in_syl");
        tmp2 =
            ffeature_int(item, "R:SylStructure.parent.R:Syllable.syl_numphones");
        tmp3 = ffeature_int(item, "R:SylStructure.parent.R:Syllable.pos_in_word");
        tmp4 =
            ffeature_int(item,
                         "R:SylStructure.parent.parent.R:Word.word_numsyls");
        sub_phrases =
            ffeature_int(item, "R:SylStructure.parent.R:Syllable.sub_phrases");
        lisp_total_phrases =
            ffeature_int(item,
                         "R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_phrases");
        sprintf(label,
                "%s^%s-%s+%s=%s@%d_%d/A:%d_%d_%d/B:%d-%d-%d@%d-%d&%d-%d#%d-%d$%d-%d!%d-%d;%d-%d|%s/C:%d+%d+%d/D:%s_%d/E:%s+%d@%d+%d&%d+%d#%d+%d/F:%s_%d/G:%d_%d/H:%d=%d@%d=%d|%s/I:%d=%d/J:%d+%d-%d",
                strcmp(seg_pp, "0") == 0 ? "x" : seg_pp, strcmp(seg_p,
                        "0") ==
                0 ? "x" : seg_p, seg_c, strcmp(seg_n, "0") == 0 ? "x" : seg_n,
                strcmp(seg_nn, "0") == 0 ? "x" : seg_nn, tmp1 + 1, tmp2 - tmp1,
                ffeature_int(item, "R:SylStructure.parent.R:Syllable.p.stress"),
                ffeature_int(item, "R:SylStructure.parent.R:Syllable.p.accented"),
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.p.syl_numphones"),
                ffeature_int(item, "R:SylStructure.parent.R:Syllable.stress"),
                ffeature_int(item, "R:SylStructure.parent.R:Syllable.accented"),
                tmp2, tmp3 + 1, tmp4 - tmp3, ffeature_int(item,
                        "R:SylStructure.parent.R:Syllable.syl_in")
                + 1, ffeature_int(item,
                                  "R:SylStructure.parent.R:Syllable.syl_out") + 1,
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.ssyl_in") + 1,
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.ssyl_out") + 1,
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.asyl_in") + 1,
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.asyl_out") + 1,
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.lisp_distance_to_p_stress"),
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.lisp_distance_to_n_stress"),
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.lisp_distance_to_p_accent"),
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.lisp_distance_to_n_accent"),
                ffeature_string(item,
                                "R:SylStructure.parent.R:Syllable.syl_vowel"),
                ffeature_int(item, "R:SylStructure.parent.R:Syllable.n.stress"),
                ffeature_int(item, "R:SylStructure.parent.R:Syllable.n.accented"),
                ffeature_int(item,
                             "R:SylStructure.parent.R:Syllable.n.syl_numphones"),
                ffeature_string(item,
                                "R:SylStructure.parent.parent.R:Word.p.gpos"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Word.p.word_numsyls"),
                ffeature_string(item, "R:SylStructure.parent.parent.R:Word.gpos"),
                tmp4, ffeature_int(item,
                                   "R:SylStructure.parent.parent.R:Word.pos_in_phrase")
                + 1, ffeature_int(item,
                                  "R:SylStructure.parent.parent.R:Word.words_out"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Word.content_words_in")
                + 1, ffeature_int(item,
                                  "R:SylStructure.parent.parent.R:Word.content_words_out")
                + 1, ffeature_int(item,
                                  "R:SylStructure.parent.parent.R:Word.lisp_distance_to_p_content"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Word.lisp_distance_to_n_content"),
                ffeature_string(item,
                                "R:SylStructure.parent.parent.R:Word.n.gpos"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Word.n.word_numsyls"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Phrase.parent.p.lisp_num_syls_in_phrase"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Phrase.parent.p.lisp_num_words_in_phrase"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_syls_in_phrase"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_words_in_phrase"),
                sub_phrases + 1, lisp_total_phrases - sub_phrases,
                ffeature_string(item,
                                "R:SylStructure.parent.parent.R:Phrase.parent.daughtern.R:SylStructure.daughtern.endtone"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Phrase.parent.n.lisp_num_syls_in_phrase"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Phrase.parent.n.lisp_num_words_in_phrase"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_syls"),
                ffeature_int(item,
                             "R:SylStructure.parent.parent.R:Phrase.parent.lisp_total_words"),
                lisp_total_phrases);
    }
}
Example #6
0
static void assign_stress(cst_item *word)
{
  int numsyls=ffeature_int(word,"word_numsyls");
  const char *gpos=ffeature_string(word,"gpos");
  const cst_item *word_in_phrase=item_as(word,"Phrase");
  const cst_item *syls=item_as(word,"SylStructure");
  const cst_item *syl=item_daughter(syls);
  const cst_item *transcription=item_as(word,"Transcription");
  int stressed=FALSE;
  int n=item_feat_present(word,"stressed_syl_num")?item_feat_int(word,"stressed_syl_num"):0;
  const char *name=item_name(word);
  const char *pname=ffeature_string(word,"R:Phrase.p.name");
  const char *nname=ffeature_string(word,"R:Phrase.n.name");
  if(cst_streq(ffeature_string(word,"R:Token.p.name"),"по")&&
     (cst_streq(name,"моему")||cst_streq(name,"своему")||cst_streq(name,"твоему")))
    {
      item_set_string(syl,"stress","1");
      return;
    }
  else if((cst_streq(name,"не")||cst_streq(name,"ни"))&&
     (cst_streq(nname,"был")||cst_streq(nname,"были")||cst_streq(nname,"было")))
    {
      item_set_string(syl,"stress","1");
      return;
    }
  else if((cst_streq(name,"был")||cst_streq(name,"были")||cst_streq(name,"было"))&&
     (cst_streq(pname,"не")||cst_streq(pname,"ни")))
    return;
  else if(cst_streq(gpos,"enc")&&item_prev(word_in_phrase))
    return;
  else if(cst_streq(gpos,"proc")&&item_next(word_in_phrase))
    return;
  if(!vowel_seg_between(item_daughter(transcription),item_last_daughter(transcription)))
    return;
  if(numsyls==1)
    {
      item_set_string(syl,"stress","1");
      return;
    }
  for(;syl;syl=item_next(syl))
    {
      if(is_stressed_vowel(item_feat_string(item_daughter(item_as(syl,"SylVowel")),"name")))
        {
          item_set_string(syl,"stress","1");
          stressed=TRUE;
        }
    }
  if(n==0)
    {
      if(stressed)
        return;
      n=val_int(cart_interpret(word,&ru_stress_cart));
      if((numsyls+n) < 0)
        {
          if(numsyls <= 4)
            n=-2;
          else
            if(numsyls <= 6)
              n=-3;
            else
              n=-4;
        }
    }
  item_set_string(item_nth_daughter(syls,(numsyls+n)),"stress","1");
}