arch
Class PhoneInventory

java.lang.Object
  extended by arch.PhoneInventory
All Implemented Interfaces:
java.io.Serializable

public class PhoneInventory
extends java.lang.Object
implements java.io.Serializable

The PhoneInventory handles storage and loading of (poly)phone inventories. It is also used within the LexicalTree to model the contained words.

Author:
sikoried
See Also:
Serialized Form

Constructor Summary
PhoneInventory()
           
 
Method Summary
 void addPolyphone(Polyphone p)
          Add a single polyphone to the inventory, ignore if already present.
 void addPolyphones(Polyphone[] ps)
          Add a list of polyphones to the inventory.
 void addPolyphonesFromLexicon(Lexicon lex)
          Add all polyphones occurring in the given Lexicon
 void clearPhoneInventory()
          Clear the inventory for a clean start.
 Polyphone getMonophone(java.lang.String phone)
          Retrieve the most general polyphone for the given phone
 Polyphone getPolyphone(java.lang.String phoneInContext)
          Retrieve a certain polyphone
 java.lang.String hierarchyAsDotFormat(boolean includeHeader)
          Generate a .dot representation of the phoneme hierarchy for a visual check
 java.lang.String hierarchyAsString()
          Get a String representation of the phone inventory, including the polyphone hierarchy.
static void main(java.lang.String[] args)
           
 void prunePhonemeHierarchy()
          Prune the unneeded polyphones, i.e.
 void prunePhonemeHierarchyByOccurrence(int minOcc, Lexicon lex, java.lang.String sentenceFile)
          Prune the phoneme hierarchy by their number of occurrence.
 void reduceToBiphone()
          Reduce the phone inventory to a mono- and biphone inventory
 void reduceToMonophone()
          Reduce the phone inventory to a monophone ONLY inventory
 void reduceToTriphone()
          Reduce the phone inventory to a mono-, bi and tri-phone inventory
 int size()
          Get the size of the phone inventory.
 java.lang.String toString()
          Return information about this PhoneInventory.
 Polyphone[] translateWord(java.lang.String[] transcription)
          Construct the Polyphone sequence for a given transcription.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PhoneInventory

public PhoneInventory()
Method Detail

addPolyphone

public void addPolyphone(Polyphone p)
Add a single polyphone to the inventory, ignore if already present. Ensures the correct order within the hierarchy.

Parameters:
p - Polyphone to insert.

addPolyphones

public void addPolyphones(Polyphone[] ps)
Add a list of polyphones to the inventory.

Parameters:
ps - Array of Polyphone instances

addPolyphonesFromLexicon

public void addPolyphonesFromLexicon(Lexicon lex)
Add all polyphones occurring in the given Lexicon

Parameters:
lex -

clearPhoneInventory

public void clearPhoneInventory()
Clear the inventory for a clean start.


getMonophone

public Polyphone getMonophone(java.lang.String phone)
Retrieve the most general polyphone for the given phone

Parameters:
phone -
Returns:

getPolyphone

public Polyphone getPolyphone(java.lang.String phoneInContext)
Retrieve a certain polyphone

Parameters:
phoneInContext - e.g. S/n/o
Returns:

hierarchyAsDotFormat

public java.lang.String hierarchyAsDotFormat(boolean includeHeader)
Generate a .dot representation of the phoneme hierarchy for a visual check

Returns:

hierarchyAsString

public java.lang.String hierarchyAsString()
Get a String representation of the phone inventory, including the polyphone hierarchy.

Returns:
the hierarchy in ASCII art

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException,
                        OutOfVocabularyException
Throws:
java.io.IOException
java.lang.ClassNotFoundException
OutOfVocabularyException

prunePhonemeHierarchy

public void prunePhonemeHierarchy()
Prune the unneeded polyphones, i.e. extra "idle" links in the phonetic hierarchy.


prunePhonemeHierarchyByOccurrence

public void prunePhonemeHierarchyByOccurrence(int minOcc,
                                              Lexicon lex,
                                              java.lang.String sentenceFile)
                                       throws java.io.IOException,
                                              OutOfVocabularyException
Prune the phoneme hierarchy by their number of occurrence.

Parameters:
minOcc - minimum number of occurrences of remaining polyphones
lex - Lexicon to transcribe the sentences
sentenceFile - file containing line-by-line sentences
Throws:
java.io.IOException
OutOfVocabularyException

reduceToBiphone

public void reduceToBiphone()
Reduce the phone inventory to a mono- and biphone inventory


reduceToMonophone

public void reduceToMonophone()
Reduce the phone inventory to a monophone ONLY inventory


reduceToTriphone

public void reduceToTriphone()
Reduce the phone inventory to a mono-, bi and tri-phone inventory


size

public int size()
Get the size of the phone inventory.

Returns:
Size of the phone inventory.

toString

public java.lang.String toString()
Return information about this PhoneInventory.

Overrides:
toString in class java.lang.Object

translateWord

public Polyphone[] translateWord(java.lang.String[] transcription)
Construct the Polyphone sequence for a given transcription. The polyphone with the longest matching context will be used.

Parameters:
transcription - word transcription including word boundaries at beginning and end!
Returns:
Polyphone sequence w/o word boundary markers