inpro.incremental.unit
Class WordIU

java.lang.Object
  extended by inpro.incremental.unit.IU
      extended by inpro.incremental.unit.WordIU
All Implemented Interfaces:
java.lang.Comparable<IU>
Direct Known Subclasses:
HesitatingSynthesisIU.HesitationIU, TextualWordIU

public class WordIU
extends IU


Nested Class Summary
private  class WordIU.ProsodicFeatures
           
 
Nested classes/interfaces inherited from class inpro.incremental.unit.IU
IU.IUUpdateListener, IU.Progress
 
Field Summary
(package private) static java.util.Map<java.lang.String,java.util.List<AVPair>> avPairs
           
(package private)  boolean isSilence
           
(package private)  edu.cmu.sphinx.linguist.dictionary.Pronunciation pron
           
private  WordIU.ProsodicFeatures prosodicFeatures
           
(package private)  java.lang.String word
           
 
Fields inherited from class inpro.incremental.unit.IU
creationTime, FIRST_IU, groundedIn, grounds, nextSameLevelLinks, previousSameLevelLink, updateListeners
 
Constructor Summary
  WordIU(edu.cmu.sphinx.linguist.dictionary.Pronunciation pron, WordIU sll, java.util.List<IU> groundedIn)
           
protected WordIU(java.lang.String word, edu.cmu.sphinx.linguist.dictionary.Pronunciation pron, WordIU sll, java.util.List<IU> groundedIn)
           
  WordIU(java.lang.String spelling, WordIU sll, java.util.List<IU> groundedIn)
           
  WordIU(WordIU sll)
          create a new silent word
 
Method Summary
 void appendMaryXML(java.lang.StringBuilder sb)
           
 java.util.List<AVPair> getAVPairs()
           
 SegmentIU getFirstSegment()
           
 SegmentIU getLastSegment()
           
 java.util.List<SegmentIU> getSegments()
           
 java.util.List<java.lang.String> getValues(java.lang.String attribute)
          Retrieves all values of an WordIU's AVPairs, given an attribute.
static double getWER(java.util.List<WordIU> a, java.util.List<WordIU> b)
          calculate the WER between two lists of words based on the levenshtein distance code adapted from http://www.merriampark.com/ldjava.htm list a is taken as the reference for word error rate normalization
 java.lang.String getWord()
           
 boolean hasAVPairs()
           
 boolean hasProsody()
           
 boolean isBackchannel()
           
 boolean isSilence()
           
private static int min(int a, int b, int c)
          three-way minimum used internally in getWER
 boolean pitchIsRising()
          precondition: only call this if hasProsody()
 boolean pronunciationEquals(edu.cmu.sphinx.linguist.dictionary.Pronunciation pron)
           
 boolean pronunciationEquals(WordIU iu)
           
static java.util.List<WordIU> removeSilentWords(java.util.List<WordIU> words)
          returns a new list with all silent words removed
static void setAVPairs(java.util.Map<java.lang.String,java.util.List<AVPair>> avPairs)
           
 void shiftBy(double offset)
          shift the start and end times of this (and possibly all following SysSegmentIUs
static boolean spellingEqual(java.util.List<WordIU> a, java.util.List<WordIU> b)
           
 boolean spellingEquals(WordIU iu)
           
 java.lang.StringBuilder toMbrolaLines()
           
 java.lang.String toPayLoad()
           
 void updateSegments(java.util.List<Label> newLabels)
           
 void updateTimings(WordIU otherWord)
          this operation updates the timings of the grounding segments to match those of another IU for the same word (in terms of spelling)
static java.lang.String wordsToString(java.util.List<WordIU> words)
          Builds a simple string from a list of wordIUs
 
Methods inherited from class inpro.incremental.unit.IU
addNextSameLevelLink, addUpdateListener, commit, compareTo, connectSLL, deepToString, duration, endTime, equals, getAge, getAmongNextSameLevelLinks, getCreationTime, getID, getNextSameLevelLink, getNextSameLevelLinks, getOngoingGroundedIU, getProgress, getSameLevelLink, ground, groundedIn, groundIn, groundIn, grounds, hashCode, isCommitted, isCompleted, isOngoing, isRevoked, isUpcoming, notifyListeners, payloadEquals, removeAllNextSameLevelLinks, removeGrin, removeGrin, reorderNextSameLevelLink, revoke, setAsTopNextSameLevelLink, setSameLevelLink, startTime, toLabelLine, toString, toTEDviewXML, updateOnGrinUpdates
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

avPairs

static java.util.Map<java.lang.String,java.util.List<AVPair>> avPairs

isSilence

final boolean isSilence

pron

final edu.cmu.sphinx.linguist.dictionary.Pronunciation pron

word

final java.lang.String word

prosodicFeatures

private WordIU.ProsodicFeatures prosodicFeatures
Constructor Detail

WordIU

public WordIU(edu.cmu.sphinx.linguist.dictionary.Pronunciation pron,
              WordIU sll,
              java.util.List<IU> groundedIn)

WordIU

public WordIU(java.lang.String spelling,
              WordIU sll,
              java.util.List<IU> groundedIn)

WordIU

protected WordIU(java.lang.String word,
                 edu.cmu.sphinx.linguist.dictionary.Pronunciation pron,
                 WordIU sll,
                 java.util.List<IU> groundedIn)

WordIU

public WordIU(WordIU sll)
create a new silent word

Parameters:
sll -
Method Detail

hasAVPairs

public boolean hasAVPairs()

getAVPairs

public java.util.List<AVPair> getAVPairs()

getValues

public java.util.List<java.lang.String> getValues(java.lang.String attribute)
Retrieves all values of an WordIU's AVPairs, given an attribute.

Parameters:
attribute - the attribute to retrieve
Returns:
the list of values of a given word's AVPairs that matched the attribute.

getSegments

public java.util.List<SegmentIU> getSegments()

getFirstSegment

public SegmentIU getFirstSegment()

getLastSegment

public SegmentIU getLastSegment()

updateSegments

public void updateSegments(java.util.List<Label> newLabels)

updateTimings

public void updateTimings(WordIU otherWord)
this operation updates the timings of the grounding segments to match those of another IU for the same word (in terms of spelling)

Parameters:
otherWord - the word to base the new timings on

pronunciationEquals

public boolean pronunciationEquals(edu.cmu.sphinx.linguist.dictionary.Pronunciation pron)

pronunciationEquals

public boolean pronunciationEquals(WordIU iu)

spellingEquals

public boolean spellingEquals(WordIU iu)

getWord

public java.lang.String getWord()

shiftBy

public void shiftBy(double offset)
shift the start and end times of this (and possibly all following SysSegmentIUs


isSilence

public boolean isSilence()

isBackchannel

public boolean isBackchannel()

setAVPairs

public static void setAVPairs(java.util.Map<java.lang.String,java.util.List<AVPair>> avPairs)

hasProsody

public boolean hasProsody()

pitchIsRising

public boolean pitchIsRising()
precondition: only call this if hasProsody()


toPayLoad

public java.lang.String toPayLoad()
Specified by:
toPayLoad in class IU

wordsToString

public static java.lang.String wordsToString(java.util.List<WordIU> words)
Builds a simple string from a list of wordIUs

Returns:
a string with the contained words separated by whitespace

toMbrolaLines

public java.lang.StringBuilder toMbrolaLines()

appendMaryXML

public void appendMaryXML(java.lang.StringBuilder sb)

removeSilentWords

public static java.util.List<WordIU> removeSilentWords(java.util.List<WordIU> words)
returns a new list with all silent words removed


spellingEqual

public static boolean spellingEqual(java.util.List<WordIU> a,
                                    java.util.List<WordIU> b)

getWER

public static double getWER(java.util.List<WordIU> a,
                            java.util.List<WordIU> b)
calculate the WER between two lists of words based on the levenshtein distance code adapted from http://www.merriampark.com/ldjava.htm list a is taken as the reference for word error rate normalization


min

private static final int min(int a,
                             int b,
                             int c)
three-way minimum used internally in getWER