Class WordDictionary


  • public class WordDictionary
    extends java.lang.Object
    Represent a word dictionary.
    This dictionary identify each sequence of chars as an unique "word" and keep information for this word (frequency, etc...)
    • Constructor Detail

      • WordDictionary

        public WordDictionary​(LanguageModel languageModel,
                              java.lang.String dictionaryId)
    • Method Detail

      • getWordId

        public int getWordId​(java.lang.String text)
      • getWord

        public Word getWord​(java.lang.String text)
      • getWord

        public Word getWord​(int wordId)
      • getValidWordForPredictionByPrefix

        public java.util.Map<BiIntegerKey,​NextWord> getValidWordForPredictionByPrefix​(java.lang.String wordPrefix,
                                                                                            PredictionParameter predictionParameter,
                                                                                            int wantedWordCount,
                                                                                            gnu.trove.set.hash.TIntHashSet wordIdsToExclude)
        Returns all the words that starts with a given prefix.
        The returned list is not sorted.
        Parameters:
        wordPrefix - prefix
        predictionParameter - prediction parameters (used to validate word to predict)
        wantedWordCount - the number of word wanted (used to stop search)
        wordIdsToExclude - to exclude word from the result set (by id)
        Returns:
        the list of all word starting with the given prefix
      • getAllWords

        public java.util.Collection<Word> getAllWords()
      • size

        public int size()
      • isExactWordWithPrefixExist

        public boolean isExactWordWithPrefixExist​(java.lang.String prefix)
      • getExactWordsWithPrefixExist

        public java.util.SortedMap<java.lang.String,​Word> getExactWordsWithPrefixExist​(java.lang.String prefix)
      • getIDGeneratorState

        public int getIDGeneratorState()
      • putUserWord

        public int putUserWord​(Token token)
      • putUserWord

        public Word putUserWord​(java.lang.String word)
      • incrementUserWord

        public void incrementUserWord​(int wordId)
      • isWordExists

        public boolean isWordExists​(java.lang.String text)
      • isTokenValidToCreateUserWord

        public boolean isTokenValidToCreateUserWord​(Token token)
      • putWordTraining

        public int putWordTraining​(java.lang.String word)
      • compact

        public void compact()
      • saveUserDictionary

        public void saveUserDictionary​(java.io.File userDictionaryFile)
                                throws java.io.IOException
        Throws:
        java.io.IOException