/** * <summary>Gets bigram probability of given symbols.</summary> * <param name="w1">first gram of bigram</param> * <param name="w2">second gram of bigram</param> * <returns>probability of bigram formed by w1 and w2.</returns> */ private double GetBiGramProbability(TSymbol w1, TSymbol w2) { try { return(rootNode.GetBiGramProbability(w1, w2)); } catch (UnseenCase unseenCase) { return(_probabilityOfUnseen[1]); } }
/** * <summary>Gets trigram probability of given symbols w1, w2 and w3.</summary> * * <param name="w1">first gram of trigram</param> * <param name="w2">second gram of trigram</param> * <param name="w3">third gram of trigram</param> * <returns>probability of given trigram.</returns> */ public double GetTriGramProbability(TSymbol w1, TSymbol w2, TSymbol w3) { if (_children.ContainsKey(w1)) { var child = _children[w1]; return(child.GetBiGramProbability(w2, w3)); } if (_unknown != null) { return(_unknown.GetBiGramProbability(w2, w3)); } throw new UnseenCase(); }