arch
Class Lexicon

java.lang.Object
  extended by arch.Lexicon

public class Lexicon
extends java.lang.Object


Nested Class Summary
static class Lexicon.Entry
          The Entry class stores a lexicon entry by its word and transcription
 
Field Summary
 java.util.LinkedList<Lexicon.Entry> entries
          lexicon entries, supposedly sorted
 
Constructor Summary
Lexicon(java.util.ArrayList<java.lang.String> alphabet)
          Generate a Lexicon using the given phonetic alphabet.
 
Method Summary
 void addEntry(java.lang.String word, java.lang.String transcription)
          Add an entry using the word and its transcription.
 Lexicon.Entry getEntry(java.lang.String word)
          Retrieve the corresponding Lexicon entry for the given word
 void insertEntry(Lexicon.Entry e)
          Insert an entry without sorting the lexicon afterwards
 void insertEntrySorted(Lexicon.Entry e)
          Insert an entry to the lexicon and sort it
static void main(java.lang.String[] args)
          Use the main program to verify a lexicon alongside with its alphabet
static Lexicon readLexiconFromFile(java.lang.String alphabetFile, java.lang.String lexiconFile)
           
 void sortEntries()
          Sort the lexicon
 java.lang.String toString()
          Get a String representation of the Lexicon
 java.lang.String[] translate(java.lang.String word)
          Use the lexicon to obtain a transcription for a given word.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

entries

public java.util.LinkedList<Lexicon.Entry> entries
lexicon entries, supposedly sorted

Constructor Detail

Lexicon

public Lexicon(java.util.ArrayList<java.lang.String> alphabet)
Generate a Lexicon using the given phonetic alphabet.

Parameters:
alphabet - list of Strings, representing the alphabet
Method Detail

addEntry

public void addEntry(java.lang.String word,
                     java.lang.String transcription)
              throws InvalidFormatException
Add an entry using the word and its transcription.

Parameters:
word -
transcription -
Throws:
InvalidFormatException - on error, however file and line number are wrong

getEntry

public Lexicon.Entry getEntry(java.lang.String word)
Retrieve the corresponding Lexicon entry for the given word

Parameters:
word -
Returns:

insertEntry

public void insertEntry(Lexicon.Entry e)
Insert an entry without sorting the lexicon afterwards

Parameters:
e -

insertEntrySorted

public void insertEntrySorted(Lexicon.Entry e)
Insert an entry to the lexicon and sort it

Parameters:
e -

main

public static void main(java.lang.String[] args)
Use the main program to verify a lexicon alongside with its alphabet

Parameters:
args -

readLexiconFromFile

public static Lexicon readLexiconFromFile(java.lang.String alphabetFile,
                                          java.lang.String lexiconFile)
                                   throws InvalidFormatException,
                                          java.io.IOException
Throws:
InvalidFormatException
java.io.IOException

sortEntries

public void sortEntries()
Sort the lexicon


toString

public java.lang.String toString()
Get a String representation of the Lexicon

Overrides:
toString in class java.lang.Object

translate

public java.lang.String[] translate(java.lang.String word)
                             throws OutOfVocabularyException
Use the lexicon to obtain a transcription for a given word. Does a binary search on the lexicon list.

Parameters:
word - requested word
Returns:
transcription as String array
Throws:
OutOfVocabularyException