From 369ca9dce7e13402ede4026e22a1b8f29e661a96 Mon Sep 17 00:00:00 2001 From: Tarun Kumar Vangani Date: Mon, 1 Aug 2016 21:10:17 +0530 Subject: [PATCH] Added Default Parameter to Support Smoothing --- text.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/text.py b/text.py index 39bbb921f..57a19d2ab 100644 --- a/text.py +++ b/text.py @@ -32,10 +32,10 @@ class NgramTextModel(CountingProbDist): You can add, sample or get P[(word1, ..., wordn)]. The method P.samples(n) builds up an n-word sequence; P.add and P.add_sequence add data.""" - def __init__(self, n, observation_sequence=[]): + def __init__(self, n, observation_sequence=[], default=0): # In addition to the dictionary of n-tuples, cond_prob is a # mapping from (w1, ..., wn-1) to P(wn | w1, ... wn-1) - CountingProbDist.__init__(self) + CountingProbDist.__init__(self, default=default) self.n = n self.cond_prob = defaultdict() self.add_sequence(observation_sequence)