Class DynamicNGramDictionary

  • All Implemented Interfaces:
    AutoCloseable

    public class DynamicNGramDictionary
    extends TrainingNGramDictionary
    Represent a TrainingNGramDictionary that can also be opened to be trained again.
    This type of dictionary is useful when using a dynamic user model : the dynamic user dictionary is loaded and trained during each session, and then saved to be used in the next sessions.
    • Constructor Detail

      • DynamicNGramDictionary

        public DynamicNGramDictionary​(int maxOrderP)
    • Method Detail

      • load

        public static DynamicNGramDictionary load​(File dictionaryFile)
                                           throws IOException
        Create and open a existing dynamic ngram dictionary.
        Parameters:
        dictionaryFile - file containing the dynamic ngram dictionary
        Returns:
        the loaded dynamic dictionary
        Throws:
        IOException - if dictionary can't be loaded
      • getRootBlockSize

        protected long getRootBlockSize()
        Overrides:
        getRootBlockSize in class TrainingNGramDictionary
        Returns:
        should return the byte count needed to save the root block (useful to shift data in file to save the root in first position in file)
      • computeD

        public double[] computeD​(TrainingConfiguration configuration)
        Description copied from class: AbstractNGramDictionary
        Compute the optimal value for d (absolute discounting parameter).
        Usually d is computed with formula :
        D = C1 / (C1 + 2 * C2)
        Where C1 = number of ngram with count == 1, and C2 = number of ngram with count == 2. Theses values are computed for each order (0 index = unigram, 1 index = bigram, etc.)
        Overrides:
        computeD in class TrainingNGramDictionary
        Parameters:
        configuration - configuration to use to compute D (can set min/max values and a D value)
        Returns:
        computed d value for this dictionary