rita.support
Class RiCMULexicon

java.lang.Object
  extended by rita.support.RiCMULexicon
All Implemented Interfaces:
com.sun.speech.freetts.lexicon.Lexicon, RiLexiconIF

public class RiCMULexicon
extends java.lang.Object
implements RiLexiconIF

Provides an implementation of a user-customizable Lexicon using CMU-style pronunciation tags and penn-style part-of-speech tags.

The implementation also allows users to define their own addenda that will be used in addition to the system addenda. If the user defines their own addenda, it values will be added to the system addenda, overriding any existing elements in the system addenda.


Method Summary
 void addAddendum(java.lang.String word, java.lang.String[] phones)
          Adds a word to the addenda.
 void addAddendum(java.lang.String word, java.lang.String pos, java.lang.String[] phones)
           
 int getAddendaCount()
          Returns the number of user addenda items added to the lexicon
static RiCMULexicon getInstance()
           
static RiCMULexicon getInstance(processing.core.PApplet p)
          Creates, loads and returns the singleton lexicon instance.
static RiCMULexicon getInstance(processing.core.PApplet p, java.lang.String basename)
          Creates, loads and returns the singleton lexicon instance.
 java.lang.String[] getPhones(java.lang.String word)
           
 java.lang.String[] getPhones(java.lang.String word, java.lang.String partOfSpeech)
          Gets the phone list for a given word.
 java.lang.String[] getPhones(java.lang.String word, java.lang.String partOfSpeech, boolean useLTS)
          Gets the phone list for a given word.
 java.lang.String[] getPosArr(java.lang.String word)
           
 java.lang.String[] getRawStresses(java.lang.String word)
          returns a '-' (denoting no mark) or 0 (unstressed) or 1 (stressed) for each phoneme
 java.util.Set getWords()
           
 java.util.Set getWords(java.lang.String regex)
           
 boolean isLoaded()
          Determines if this lexicon is loaded.
 boolean isSyllableBoundary(java.util.List syllablePhones, java.lang.String[] wordPhones, int currentWordPhone)
          Determines if the currentPhone represents a new syllable boundary.
 java.util.Iterator iterator()
           
 java.util.Iterator iterator(boolean randomStartOffset)
           
 java.util.Set keySet()
           
 void load()
          Loads the data into this lexicon.
 java.lang.String lookupPhonemesAndStresses(java.lang.String word)
           
 java.lang.String lookupRaw(java.lang.String word)
           
static void main(java.lang.String[] args)
           
 void removeAddendum(java.lang.String word, java.lang.String partOfSpeech)
          Removes a word from the lexicon.
 int size()
           
static void writeLexicon2(RiCMULexicon lex)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static RiCMULexicon getInstance()

getInstance

public static RiCMULexicon getInstance(processing.core.PApplet p)
Creates, loads and returns the singleton lexicon instance.


getInstance

public static RiCMULexicon getInstance(processing.core.PApplet p,
                                       java.lang.String basename)
Creates, loads and returns the singleton lexicon instance.


getAddendaCount

public int getAddendaCount()
Returns the number of user addenda items added to the lexicon


isLoaded

public boolean isLoaded()
Determines if this lexicon is loaded.

Specified by:
isLoaded in interface com.sun.speech.freetts.lexicon.Lexicon
Returns:
true if the lexicon is loaded

load

public void load()
          throws java.io.IOException
Loads the data into this lexicon. If the

Specified by:
load in interface com.sun.speech.freetts.lexicon.Lexicon
Throws:
java.io.IOException - if errors occur during loading

getPhones

public java.lang.String[] getPhones(java.lang.String word,
                                    java.lang.String partOfSpeech)
Gets the phone list for a given word. If a phone list cannot be found, returns null. The format is lexicon dependent. If the part of speech does not matter, pass in null.

Specified by:
getPhones in interface com.sun.speech.freetts.lexicon.Lexicon

getPhones

public java.lang.String[] getPhones(java.lang.String word,
                                    java.lang.String partOfSpeech,
                                    boolean useLTS)
Gets the phone list for a given word. If a phone list cannot be found, null is returned. The partOfSpeech is implementation dependent, but null always matches.

Specified by:
getPhones in interface com.sun.speech.freetts.lexicon.Lexicon

addAddendum

public void addAddendum(java.lang.String word,
                        java.lang.String[] phones)
Adds a word to the addenda.


removeAddendum

public void removeAddendum(java.lang.String word,
                           java.lang.String partOfSpeech)
Removes a word from the lexicon.

Specified by:
removeAddendum in interface com.sun.speech.freetts.lexicon.Lexicon
Parameters:
word - the word to remove
partOfSpeech - the part of speech

size

public int size()

isSyllableBoundary

public boolean isSyllableBoundary(java.util.List syllablePhones,
                                  java.lang.String[] wordPhones,
                                  int currentWordPhone)
Determines if the currentPhone represents a new syllable boundary.

Specified by:
isSyllableBoundary in interface com.sun.speech.freetts.lexicon.Lexicon
Parameters:
syllablePhones - the phones in the current syllable so far
wordPhones - the phones for the whole word
currentWordPhone - the word phone in question
Returns:
true if the word phone in question is on a syllable boundary; otherwise false.

getWords

public java.util.Set getWords()

lookupRaw

public java.lang.String lookupRaw(java.lang.String word)
Invisible:

lookupPhonemesAndStresses

public java.lang.String lookupPhonemesAndStresses(java.lang.String word)
Invisible:

iterator

public java.util.Iterator iterator()

keySet

public java.util.Set keySet()

iterator

public java.util.Iterator iterator(boolean randomStartOffset)

getWords

public java.util.Set getWords(java.lang.String regex)

getPosArr

public java.lang.String[] getPosArr(java.lang.String word)
Specified by:
getPosArr in interface RiLexiconIF

getPhones

public java.lang.String[] getPhones(java.lang.String word)

getRawStresses

public java.lang.String[] getRawStresses(java.lang.String word)
returns a '-' (denoting no mark) or 0 (unstressed) or 1 (stressed) for each phoneme


addAddendum

public void addAddendum(java.lang.String word,
                        java.lang.String pos,
                        java.lang.String[] phones)
Specified by:
addAddendum in interface com.sun.speech.freetts.lexicon.Lexicon

writeLexicon2

public static void writeLexicon2(RiCMULexicon lex)
                          throws java.io.IOException
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)