cmu_postlex.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*************************************************************************/
  2. /* */
  3. /* Language Technologies Institute */
  4. /* Carnegie Mellon University */
  5. /* Copyright (c) 2001-2008 */
  6. /* All Rights Reserved. */
  7. /* */
  8. /* Permission is hereby granted, free of charge, to use and distribute */
  9. /* this software and its documentation without restriction, including */
  10. /* without limitation the rights to use, copy, modify, merge, publish, */
  11. /* distribute, sublicense, and/or sell copies of this work, and to */
  12. /* permit persons to whom this work is furnished to do so, subject to */
  13. /* the following conditions: */
  14. /* 1. The code must retain the above copyright notice, this list of */
  15. /* conditions and the following disclaimer. */
  16. /* 2. Any modifications must be clearly marked as such. */
  17. /* 3. Original authors' names are not deleted. */
  18. /* 4. The authors' names are not used to endorse or promote products */
  19. /* derived from this software without specific prior written */
  20. /* permission. */
  21. /* */
  22. /* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
  23. /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
  24. /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
  25. /* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
  26. /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
  27. /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
  28. /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
  29. /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
  30. /* THIS SOFTWARE. */
  31. /* */
  32. /*************************************************************************/
  33. /* Author: Alan W Black (awb@cs.cmu.edu) */
  34. /* Date: August 2008 */
  35. /*************************************************************************/
  36. /* Moved the CMU lexicon specific postlexical rules into cmulex itself */
  37. /*************************************************************************/
  38. #include "flite.h"
  39. static void apostrophe_s(cst_utterance *u)
  40. {
  41. cst_item *s;
  42. cst_item *schwa;
  43. cst_phoneset *ps=0;
  44. const char *pname, *word;
  45. ps = val_phoneset(feat_val(u->features,"phoneset"));
  46. for (s=item_next(relation_head(utt_relation(u,"Segment")));
  47. s; s=item_next(s))
  48. {
  49. word = val_string(ffeature(s, "R:SylStructure.parent.parent.name"));
  50. if (cst_streq("'s", word))
  51. {
  52. pname = item_feat_string(item_prev(s),"name");
  53. if ((strchr("fa",*phone_feature_string(ps,pname,"ctype")) != NULL)
  54. && (strchr("dbg",
  55. *phone_feature_string(ps,pname,"cplace")) == NULL))
  56. /* needs a schwa */
  57. {
  58. schwa = item_prepend(s,NULL);
  59. item_set_string(schwa,"name","ax");
  60. item_prepend(item_as(s,"SylStructure"),schwa);
  61. }
  62. else if (cst_streq("-",phone_feature_string(ps,pname,"cvox")))
  63. item_set_string(s,"name","s");
  64. }
  65. else if (cst_streq("'ve", word)
  66. || cst_streq("'ll", word)
  67. || cst_streq("'d", word))
  68. {
  69. if (cst_streq("-",ffeature_string(s,"p.ph_vc")))
  70. {
  71. schwa = item_prepend(s,NULL);
  72. item_set_string(schwa,"name","ax");
  73. item_prepend(item_as(s,"SylStructure"),schwa);
  74. }
  75. }
  76. }
  77. }
  78. static void the_iy_ax(cst_utterance *u)
  79. {
  80. const cst_item *i;
  81. const char *word;
  82. for (i = relation_head(utt_relation(u, "Segment")); i; i = item_next(i))
  83. {
  84. if (cst_streq("ax", item_name(i)))
  85. {
  86. word = ffeature_string(i,"R:SylStructure.parent.parent.name");
  87. if (cst_streq("the", word)
  88. && cst_streq("+", ffeature_string(i,"n.ph_vc")))
  89. item_set_string(i, "name", "iy");
  90. }
  91. }
  92. }
  93. cst_utterance *cmu_postlex(cst_utterance *u)
  94. {
  95. /* Post lexical rules */
  96. apostrophe_s(u);
  97. the_iy_ax(u);
  98. return u;
  99. }