示例#1
0
文件: distribute.py 项目: Glank/rdp
 def __init__(self, n, strings):
     if n is None:
         assert(strings is None)
         return
     ngpol = NGramPOL(n)
     for s in strings:
         ngpol.add(s)
     sample = [ngpol.rate(s) for s in strings]
     dist = SampleDistribution(sample)
     self.ngpol = ngpol
     self.dist = dist
示例#2
0
文件: distribute.py 项目: Glank/rdp
 def fromfile(f):
     s = NgramProbSet(None,None)
     s.dist = pickle.load(f)
     s.ngpol = NGramPOL.fromfile(f)
     return s