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.lexicon;
13 import java.util.List;
14 import java.io.IOException;
17 * Provides the phone list for words. A Lexicon is composed of three
18 * pieces: an addenda, the compiled form, and the letter to sound
21 * <li>The addenda either contains Word instances that are not in
22 * the compiled form, or it contains Word instances that replace
23 * definitions in the compiled form. The addenda is meant to be
24 * relatively small (e.g., 10's of words).
25 * <li>The compiled form is meant to hold a large number of words
26 * (e.g., 10's of thousands of words) and provide a very efficient
27 * means for finding those words.
28 * <li>The letter to sound rules will attempt to find a definition for
29 * a word not found in either the addenda or compiled form.
32 public interface Lexicon {
34 * Gets the phone list for a given word. If a phone list cannot
35 * be found, <code>null</code> is returned. The
36 * <code>partOfSpeech</code> is implementation dependent, but
37 * <code>null</code> always matches.
39 * @param word the word to find
40 * @param partOfSpeech the part of speech or <code>null</code>
42 * @return the list of phones for word or null
44 public String[] getPhones(String word, String partOfSpeech);
47 * Gets the phone list for a given word. If a phone list cannot
48 * be found, <code>null</code> is returned. The
49 * <code>partOfSpeech</code> is implementation dependent, but
50 * <code>null</code> always matches.
52 * @param word the word to find
53 * @param partOfSpeech the part of speech or <code>null</code>
54 * @param useLTS whether to use the letter-to-sound rules when
55 * the word is not in the lexicon.
57 * @return the list of phones for word or null
59 public String[] getPhones(String word, String partOfSpeech, boolean useLTS);
62 * Adds a word to the addenda. The
63 * part of speech is implementation dependent.
65 * @param word the word to add
66 * @param partOfSpeech the part of speech or <code>null</code>
69 public void addAddendum(String word, String partOfSpeech, String[] phones);
72 * Removes a word from the addenda. Both the part of speech and
73 * word must be an exact match.
75 * @param word the word to add
76 * @param partOfSpeech the part of speech
78 public void removeAddendum(String word, String partOfSpeech);
81 * Determines if the <code>currentWordPhone</code> represents a
82 * new syllable boundary.
84 * @param syllablePhones the phones in the current syllable so far
85 * @param wordPhones the phones for the whole word
86 * @param currentWordPhone the word phone in question
88 * @return <code>true</code> if the phone is a new boundary
90 public boolean isSyllableBoundary(List syllablePhones,
92 int currentWordPhone);
95 * Loads this lexicon. The loading of a lexicon need not be done
98 * @throws IOException if an error occurs while loading
100 public void load() throws IOException;
104 * Determines if this lexicon is loaded.
106 * @return <code>true</code> if the lexicon is loaded
108 public boolean isLoaded();