| 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 ([email protected]) */ |
| 34 | /* Date: August 2008 */ |
| 35 | /*************************************************************************/ |
| 36 | /* Moved the CMU lexicon specific postlexical rules into cmulex itself */ |
| 37 | /*************************************************************************/ |
| 38 | |
| 39 | #include "flite.h" |
| 40 | |
| 41 | static void apostrophe_s(cst_utterance *u) |
| 42 | { |
| 43 | cst_item *s; |
| 44 | cst_item *schwa; |
| 45 | cst_phoneset *ps=0; |
| 46 | const char *pname, *word; |
| 47 | |
| 48 | ps = val_phoneset(feat_val(u->features,"phoneset")); |
| 49 | |
| 50 | for (s=item_next(relation_head(utt_relation(u,"Segment"))); |
| 51 | s; s=item_next(s)) |
| 52 | { |
| 53 | word = val_string(ffeature(s, "R:SylStructure.parent.parent.name")); |
| 54 | if (cst_streq("'s", word)) |
| 55 | { |
| 56 | pname = item_feat_string(item_prev(s),"name"); |
| 57 | if ((strchr("fa",*phone_feature_string(ps,pname,"ctype")) != NULL) |
| 58 | && (strchr("dbg", |
| 59 | *phone_feature_string(ps,pname,"cplace")) == NULL)) |
| 60 | /* needs a schwa */ |
| 61 | { |
| 62 | schwa = item_prepend(s,NULL); |
| 63 | item_set_string(schwa,"name","ax"); |
| 64 | item_prepend(item_as(s,"SylStructure"),schwa); |
| 65 | } |
| 66 | else if (cst_streq("-",phone_feature_string(ps,pname,"cvox"))) |
| 67 | item_set_string(s,"name","s"); |
| 68 | } |
| 69 | else if (cst_streq("'ve", word) |
| 70 | || cst_streq("'ll", word) |
| 71 | || cst_streq("'d", word)) |
| 72 | { |
| 73 | if (cst_streq("-",ffeature_string(s,"p.ph_vc"))) |
| 74 | { |
| 75 | schwa = item_prepend(s,NULL); |
| 76 | item_set_string(schwa,"name","ax"); |
| 77 | item_prepend(item_as(s,"SylStructure"),schwa); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | } |
| 83 | |
| 84 | static void the_iy_ax(cst_utterance *u) |
| 85 | { |
| 86 | const cst_item *i; |
| 87 | const char *word; |
| 88 | |
| 89 | for (i = relation_head(utt_relation(u, "Segment")); i; i = item_next(i)) |
| 90 | { |
| 91 | if (cst_streq("ax", item_name(i))) |
| 92 | { |
| 93 | word = ffeature_string(i,"R:SylStructure.parent.parent.name"); |
| 94 | if (cst_streq("the", word) |
| 95 | && cst_streq("+", ffeature_string(i,"n.ph_vc"))) |
| 96 | item_set_string(i, "name", "iy"); |
| 97 | } |
| 98 | |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | cst_utterance *cmu_postlex(cst_utterance *u) |
| 103 | { |
| 104 | /* Post lexical rules */ |
| 105 | |
| 106 | apostrophe_s(u); |
| 107 | the_iy_ax(u); |
| 108 | |
| 109 | return u; |
| 110 | } |