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.cart;
13 import java.util.logging.Level;
14 import java.util.logging.Logger;
16 import com.sun.speech.freetts.Item;
17 import com.sun.speech.freetts.ProcessException;
18 import com.sun.speech.freetts.Relation;
19 import com.sun.speech.freetts.Utterance;
20 import com.sun.speech.freetts.UtteranceProcessor;
23 * Creates a <code>Relation.PHRASE</code> relation, grouping
24 * <code>Relation.WORD</code> relations by breaks.
26 * @see Relation#PHRASE
29 public class Phraser implements UtteranceProcessor {
30 /** Logger instance. */
31 private static final Logger LOGGER =
32 Logger.getLogger(UtteranceProcessor.class.getName());
35 * The CART used for this Phrasing UtteranceProcessor. It is
36 * passed into the constructor.
38 protected final CART cart;
41 * Creates a new Phrasing UtteranceProcessor with the given
42 * CART. The phrasing CART is expected to return "BB" values
45 * @param cart a phrasing CART
47 public Phraser(CART cart) {
52 * Creates a <code>Relation.PHRASE</code> relation, grouping
53 * <code>Relation.WORD</code> relations by breaks.
54 * Depends upon a phrasing CART that returns strings containing
55 * "BB" for big breaks.
57 * @param utterance the utterance to process
59 * @throws ProcessException if a problem is encountered during the
60 * processing of the utterance
62 public void processUtterance(Utterance utterance) throws ProcessException {
63 Relation relation = utterance.createRelation(Relation.PHRASE);
65 for (Item w = utterance.getRelation(Relation.WORD).getHead();
66 w != null; w = w.getNext()) {
68 p = relation.appendItem();
69 p.getFeatures().setString("name","BB");
72 String results = (String) cart.interpret(w);
74 if (LOGGER.isLoggable(Level.FINER)) {
75 LOGGER.finer("word: " + w + ", results: " + results);
77 if (results.equals("BB")) {
83 // inherited from Object
84 public String toString() {