Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5574d77

Browse files
reachtarunherenorvig
authored andcommitted
Added Default Parameter to Support Smoothing (aimacode#246)
1 parent 8ec6012 commit 5574d77

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class NgramTextModel(CountingProbDist):
3232
You can add, sample or get P[(word1, ..., wordn)]. The method P.samples(n)
3333
builds up an n-word sequence; P.add and P.add_sequence add data."""
3434

35-
def __init__(self, n, observation_sequence=[]):
35+
def __init__(self, n, observation_sequence=[], default=0):
3636
# In addition to the dictionary of n-tuples, cond_prob is a
3737
# mapping from (w1, ..., wn-1) to P(wn | w1, ... wn-1)
38-
CountingProbDist.__init__(self)
38+
CountingProbDist.__init__(self, default=default)
3939
self.n = n
4040
self.cond_prob = defaultdict()
4141
self.add_sequence(observation_sequence)

0 commit comments

Comments
 (0)