Interface Lexicon

  • All Known Implementing Classes:
    CMULexicon, CMUTimeLexicon, LexiconImpl

    public interface Lexicon
    Provides the phone list for words. A Lexicon is composed of three pieces: an addenda, the compiled form, and the letter to sound rules.
    • The addenda either contains Word instances that are not in the compiled form, or it contains Word instances that replace definitions in the compiled form. The addenda is meant to be relatively small (e.g., 10's of words).
    • The compiled form is meant to hold a large number of words (e.g., 10's of thousands of words) and provide a very efficient means for finding those words.
    • The letter to sound rules will attempt to find a definition for a word not found in either the addenda or compiled form.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addAddendum​(java.lang.String word, java.lang.String partOfSpeech, java.lang.String[] phones)
      Adds a word to the addenda.
      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.
      boolean isLoaded()
      Determines if this lexicon is loaded.
      boolean isSyllableBoundary​(java.util.List syllablePhones, java.lang.String[] wordPhones, int currentWordPhone)
      Determines if the currentWordPhone represents a new syllable boundary.
      void load()
      Loads this lexicon.
      void removeAddendum​(java.lang.String word, java.lang.String partOfSpeech)
      Removes a word from the addenda.
    • Method Detail

      • getPhones

        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, null is returned. The partOfSpeech is implementation dependent, but null always matches.
        Parameters:
        word - the word to find
        partOfSpeech - the part of speech or null
        Returns:
        the list of phones for word or null
      • getPhones

        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.
        Parameters:
        word - the word to find
        partOfSpeech - the part of speech or null
        useLTS - whether to use the letter-to-sound rules when the word is not in the lexicon.
        Returns:
        the list of phones for word or null
      • addAddendum

        void addAddendum​(java.lang.String word,
                         java.lang.String partOfSpeech,
                         java.lang.String[] phones)
        Adds a word to the addenda. The part of speech is implementation dependent.
        Parameters:
        word - the word to add
        partOfSpeech - the part of speech or null
      • removeAddendum

        void removeAddendum​(java.lang.String word,
                            java.lang.String partOfSpeech)
        Removes a word from the addenda. Both the part of speech and word must be an exact match.
        Parameters:
        word - the word to add
        partOfSpeech - the part of speech
      • isSyllableBoundary

        boolean isSyllableBoundary​(java.util.List syllablePhones,
                                   java.lang.String[] wordPhones,
                                   int currentWordPhone)
        Determines if the currentWordPhone represents a new syllable boundary.
        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 phone is a new boundary
      • load

        void load()
           throws java.io.IOException
        Loads this lexicon. The loading of a lexicon need not be done in the constructor.
        Throws:
        java.io.IOException - if an error occurs while loading
      • isLoaded

        boolean isLoaded()
        Determines if this lexicon is loaded.
        Returns:
        true if the lexicon is loaded