Example #1
0
        private static Dictionary <string, double> LaplacianSmoothing(Gram predicateState, List <string> dictionary) //this list dictionary may contain words not in the official dictionary such as a misspelling of currentword
        {
            Dictionary <string, double> probabilityDistribution = new Dictionary <string, double>();
            int predicateFrequency = predicateState.getCount();

            predicateFrequency += dictionary.Count;     // the plus one smoothing
            foreach (string word in dictionary)
            {
                int count = 1;                          // the plus one smoothing
                count += predicateState.NextWordCount(word);
                probabilityDistribution.Add(word, count / (double)predicateFrequency);
            }
            return(probabilityDistribution);
        }
Example #2
0
 public Model(int depth)
 {
     model      = new Gram("");
     modelDepth = depth;
     eventCount = 0;
 }