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); }
public Model(int depth) { model = new Gram(""); modelDepth = depth; eventCount = 0; }