Beispiel #1
0
 def add(self, ngram):
     """Count 1 for P[(w1, ..., wn)] and for P(wn | (w1, ..., wn-1)"""
     CountingProbDist.add(self, ngram)
     self.cond_prob[ngram[:-1]].add(ngram[-1])
Beispiel #2
0
 def add(self, ngram):
     """Count 1 for P[(w1, ..., wn)] and for P(wn | (w1, ..., wn-1)"""
     CountingProbDist.add(self, ngram)
     if ngram[:-1] not in self.cond_prob:
         self.cond_prob[ngram[:-1]] = CountingProbDist()
     self.cond_prob[ngram[:-1]].add(ngram[-1])