2 * Portions Copyright 2001 Sun Microsystems, Inc.
3 * Portions Copyright 1999-2001 Language Technologies Institute,
4 * Carnegie Mellon University.
5 * All Rights Reserved. Use is subject to license terms.
7 * See the file "license.terms" for information on usage and
8 * redistribution of this file, and for a DISCLAIMER OF ALL
11 package com.sun.speech.freetts;
13 import java.io.PrintWriter;
15 import com.sun.speech.freetts.util.Utilities;
18 * Represents an ordered set of <code>Items</code> and their associated
19 * children. A relation has a name and a list of items, and is
20 * added to an <code>Utterance</code> via an <code>UtteranceProcessor</code>.
22 public class Relation implements Dumpable {
24 private Utterance owner;
29 * Name of the relation that contains tokens from the original
30 * input text. This is the first thing to be added to the
35 public static final String TOKEN = "Token";
38 * Name of the relation that contains the normalized version of
39 * the original input text.
43 public static final String WORD = "Word";
46 * Name of the relation that groups elements from the Word relation
49 public static final String PHRASE = "Phrase";
52 * Name of the relation that contains the ordered list of the
53 * smallest units of speech (typically phonemes) for the entire
57 * @see #SYLLABLE_STRUCTURE
61 public static final String SEGMENT = "Segment";
64 * Name of the relation that contains the description of the
65 * syllables for the Utterance. This is typically added to the
66 * utterance at the same time as the <code>Segment</code> and
67 * <code>SylStructure</code> relations.
70 * @see #SYLLABLE_STRUCTURE
74 public static final String SYLLABLE = "Syllable";
77 * Name of the relation that contains the syllable structure
85 public static final String SYLLABLE_STRUCTURE = "SylStructure";
88 * Name of the relation that maps fundamental frequency targets
89 * to absolute times for wave to be generated from the utterance.
91 public static final String TARGET = "Target";
94 * Name of the relation that contains the ordered list of the
95 * units from the unit database that will be used to create
96 * the synthesized wave.
98 public static final String UNIT = "Unit";
101 * Creates a relation.
103 * @param name the name of the Relation
104 * @param owner the utterance that contains this relation
106 Relation(String name, Utterance owner) {
114 * Retrieves the name of this Relation.
116 * @return the name of this Relation
118 public String getName() {
123 * Gets the head of the item list.
125 * @return the head item
127 public Item getHead() {
132 * Sets the head of the item list.
134 * @param item the new head item
136 void setHead(Item item) {
141 * Gets the tail of the item list.
143 * @return the tail item
145 public Item getTail() {
150 * Sets the tail of the item list.
152 * @param item the new tail item
154 void setTail(Item item) {
159 * Adds a new item to this relation. The item added does not share
160 * its contents with any other item.
162 * @return the newly added item
164 public Item appendItem() {
165 return appendItem(null);
169 * Adds a new item to this relation. The item added shares its
170 * contents with the original item.
172 * @param originalItem the ItemContents that will be
173 * shared by the new item
175 * @return the newly added item
177 public Item appendItem(Item originalItem) {
178 ItemContents contents;
181 if (originalItem == null) {
184 contents = originalItem.getSharedContents();
186 newItem = new Item(this, contents);
192 tail.attach(newItem);
200 * Returns the utterance that contains this relation.
202 * @return the utterance that contains this relation
204 public Utterance getUtterance() {
210 * Dumps this relation to the print writer.
212 * @param pw the output stream
214 * @param pad the padding
216 * @param title the title for the dump
218 public void dump(PrintWriter pw, int pad, String title) {
219 Utilities.dump(pw, pad, "========= Relation: " + title +
222 while (item != null) {
223 item.dump(pw, pad + 4, title);
224 item = item.getNext();