rita.support
Class RiPhrase

java.lang.Object
  extended by rita.support.Featured
      extended by rita.support.RiPhrase
All Implemented Interfaces:
java.lang.CharSequence, processing.core.PConstants, FeaturedIF, RiCharSequence, RiConstants

public class RiPhrase
extends Featured
implements java.lang.CharSequence, RiCharSequence

Utility object for representing phrases which can be sent to the speech engine.

Invisible:

Field Summary
 
Fields inherited from class rita.support.Featured
CHUNKS, PARSE, VALUE_UNKNOWN
 
Fields inherited from interface rita.support.RiConstants
BEHAVIOR_COMPLETED, BOUNDING_BOX_ALPHA, BRILL_POS_TAGGER, EASE_IN, EASE_IN_CUBIC, EASE_IN_EXPO, EASE_IN_OUT, EASE_IN_OUT_CUBIC, EASE_IN_OUT_EXPO, EASE_IN_OUT_QUARTIC, EASE_IN_OUT_SINE, EASE_IN_QUARTIC, EASE_IN_SINE, EASE_OUT, EASE_OUT_CUBIC, EASE_OUT_EXPO, EASE_OUT_QUARTIC, EASE_OUT_SINE, ESS, FADE_COLOR, FADE_IN, FADE_OUT, FADE_TO_TEXT, FIRST_PERSON, FUTURE_TENSE, ID, LERP, LINEAR, MAXENT_POS_TAGGER, MINIM, MOVE, MUTABLE, PAST_TENSE, PHONEME_BOUNDARY, PHONEMES, PLING_STEMMER, PLURAL, PORTER_STEMMER, POS, PRESENT_TENSE, SCALE_TO, SECOND_PERSON, SENTENCE_BOUNDARY, SINGULAR, SONIA, SPEECH_COMPLETED, STRESSES, SYLLABLE_BOUNDARY, SYLLABLES, TEXT, TEXT_ENTERED, THIRD_PERSON, TIMER, TIMER_COMPLETED, TIMER_TICK, TOKENS, UNKNOWN, WORD_BOUNDARY
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
RiPhrase()
           
RiPhrase(processing.core.PApplet p, java.lang.CharSequence phrase)
           
RiPhrase(processing.core.PApplet p, com.sun.speech.freetts.Utterance utterance, java.lang.CharSequence phrase)
           
RiPhrase(java.lang.String phrase)
           
 
Method Summary
 java.lang.String addPosFeature()
           
static java.lang.String addPosFeature(java.lang.String[] toks, java.util.Map featureMap)
           
 char charAt(int index)
           
 int charCount()
           
 RiPhrase copy()
           
static java.util.Map createFeatureMap(processing.core.PApplet p, java.lang.CharSequence phrase)
           
 void dumpFeatures()
           
 boolean equals(java.lang.Object obj)
           
 int firstIndexOf(java.lang.String word)
          Returns index of first token matching word or -1 if not found
 com.sun.speech.freetts.Utterance getDelegate()
           
 java.lang.String getFeatureString()
           
 java.lang.String[] getPhonemeArray()
           
 java.lang.String getPhonemes()
           
 java.lang.String[] getPos()
           
 java.lang.String getPos(java.lang.String word)
          Returns a String representing the pos for the first index of word in the phrase, or null if there is no such word.
 java.lang.String getPosAt(int wordIdx)
           
 java.lang.String getPosStr()
           
 RiString getRiString()
          Returns an RiString (String + Feature-Map) representation of the phrase
 java.lang.String getStresses()
           
 java.lang.String getSyllables()
           
 java.lang.String getText()
           
 java.lang.String[] getTokenArray()
           
 java.lang.String getTokens()
           
 java.lang.String getWordAt(int i)
           
 int getWordCount()
           
 java.lang.String[] getWords()
           
 int[] indexOf(java.lang.String word)
           
 boolean insertWordAt(java.lang.String newWord, int wordIdx)
           
 boolean isMutable()
           
 int lastIndexOf(java.lang.String word)
          Returns the index of the last token matching word or -1 if not found
 int length()
          Returns the number of characters in the phrase
static void main(java.lang.String[] args)
           
 int numWords()
           
 int replaceAny(int wordIdx, java.lang.String pos, java.lang.String newWord)
          Replaces any word with the given 'pos' by 'newWord' starting at word at 'wordIdx' in the string.
 int replaceAny(java.lang.String pos, java.lang.String newWord)
          Replaces a single word with the given 'pos' by 'newWord' starting at a random location in the string.
 boolean replaceWordAt(int wordNum, java.lang.String newWord)
          Replaces the word at index 'wordNum' with 'newWord' As usual, the first word is at index 0.
 void setMutable(boolean mutable)
           
 void setSpeakable(com.sun.speech.freetts.FreeTTSSpeakable speakable)
           
 java.lang.CharSequence subSequence(int start, int end)
           
 int syllableCount()
           
 java.lang.String toString()
           
 java.lang.String wordAtCharPos(int pos)
          Returns closest token to 'pos' of char in Phrase
 int wordIdxAtCharPos(int position)
          Returns index of the word closest to position in the Phrase
 
Methods inherited from class rita.support.Featured
addFeature, addFeature, appendFeature, asFeature, asFeature, asFeature, asFeature, asFeature, clearFeatures, fromStrings, getAvailableFeatures, getFeature, getFeatures, getFeatures, getId, hasFeature, removeFeature, setFeatures, toStrings
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface rita.support.FeaturedIF
addFeature, clearFeatures, getAvailableFeatures, getFeature, getFeatures, hasFeature, removeFeature, setFeatures
 

Constructor Detail

RiPhrase

public RiPhrase()

RiPhrase

public RiPhrase(java.lang.String phrase)
         throws RiTaException
Throws:
RiTaException

RiPhrase

public RiPhrase(processing.core.PApplet p,
                java.lang.CharSequence phrase)
         throws RiTaException
Throws:
RiTaException

RiPhrase

public RiPhrase(processing.core.PApplet p,
                com.sun.speech.freetts.Utterance utterance,
                java.lang.CharSequence phrase)
Method Detail

getRiString

public RiString getRiString()
Returns an RiString (String + Feature-Map) representation of the phrase


getDelegate

public com.sun.speech.freetts.Utterance getDelegate()

createFeatureMap

public static java.util.Map createFeatureMap(processing.core.PApplet p,
                                             java.lang.CharSequence phrase)

replaceWordAt

public boolean replaceWordAt(int wordNum,
                             java.lang.String newWord)
Replaces the word at index 'wordNum' with 'newWord' As usual, the first word is at index 0.

Parameters:
newWord -
wordNum -
Returns:
true if the replacement was successful

replaceAny

public int replaceAny(java.lang.String pos,
                      java.lang.String newWord)
Replaces a single word with the given 'pos' by 'newWord' starting at a random location in the string.

Parameters:
newWord -
pos -
Returns:
true if the replacement was successful

replaceAny

public int replaceAny(int wordIdx,
                      java.lang.String pos,
                      java.lang.String newWord)
Replaces any word with the given 'pos' by 'newWord' starting at word at 'wordIdx' in the string.

Parameters:
newWord -
wordIdx -
pos -
Returns:
true if the replacement was successful

copy

public RiPhrase copy()

syllableCount

public int syllableCount()

lastIndexOf

public int lastIndexOf(java.lang.String word)
Returns the index of the last token matching word or -1 if not found


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
Parameters:
obj -
See Also:
Object.equals(java.lang.Object)

setSpeakable

public void setSpeakable(com.sun.speech.freetts.FreeTTSSpeakable speakable)
Parameters:
speakable -
See Also:
Utterance.setSpeakable(com.sun.speech.freetts.FreeTTSSpeakable)

dumpFeatures

public void dumpFeatures()

getFeatureString

public java.lang.String getFeatureString()

toString

public java.lang.String toString()
Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class Featured
See Also:
Object.toString()

getText

public java.lang.String getText()
Specified by:
getText in interface FeaturedIF
Overrides:
getText in class Featured

getWordAt

public java.lang.String getWordAt(int i)

wordAtCharPos

public java.lang.String wordAtCharPos(int pos)
Returns closest token to 'pos' of char in Phrase


wordIdxAtCharPos

public int wordIdxAtCharPos(int position)
Returns index of the word closest to position in the Phrase


getWordCount

public int getWordCount()

indexOf

public int[] indexOf(java.lang.String word)

firstIndexOf

public int firstIndexOf(java.lang.String word)
Returns index of first token matching word or -1 if not found


charCount

public int charCount()

getWords

public java.lang.String[] getWords()

getPosStr

public java.lang.String getPosStr()

addPosFeature

public java.lang.String addPosFeature()

addPosFeature

public static java.lang.String addPosFeature(java.lang.String[] toks,
                                             java.util.Map featureMap)

getPos

public java.lang.String[] getPos()

getPosAt

public java.lang.String getPosAt(int wordIdx)

getStresses

public java.lang.String getStresses()

getSyllables

public java.lang.String getSyllables()

getPhonemes

public java.lang.String getPhonemes()

getPhonemeArray

public java.lang.String[] getPhonemeArray()

getTokens

public java.lang.String getTokens()

getTokenArray

public java.lang.String[] getTokenArray()

isMutable

public boolean isMutable()

setMutable

public void setMutable(boolean mutable)

getPos

public java.lang.String getPos(java.lang.String word)
Returns a String representing the pos for the first index of word in the phrase, or null if there is no such word.

See Also:
firstIndexOf(String)

charAt

public char charAt(int index)
Specified by:
charAt in interface java.lang.CharSequence

length

public int length()
Returns the number of characters in the phrase

Specified by:
length in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Specified by:
subSequence in interface java.lang.CharSequence

insertWordAt

public boolean insertWordAt(java.lang.String newWord,
                            int wordIdx)

numWords

public int numWords()

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception