Exemple #1
0
 def __init__(self, ticks):
     super(TimeModel, self).__init__()
     self.hourdist = DataItem([(i, 0) for i in range(6)])
     self.wdaydist = DataItem([(i, 0) for i in range(7)])
     self.mdaydist = DataItem([(i, 0) for i in range(32)])
     if isinstance(ticks[0], datetime):
         for i in range(len(ticks)):
             ticks[i] = ticks[i].timetuple()
     for tick in ticks:
         self.hourdist[tick.tm_hour / 4] += 1
         self.mdaydist[tick.tm_mday] += 1
         self.wdaydist[tick.tm_wday] += 1
     self.hourdist = norm_v1(self.hourdist)
     self.wdaydist = norm_v1(self.wdaydist)
     self.mdaydist = norm_v1(self.mdaydist)
Exemple #2
0
 def __init__(self, ticks):
     super(TimeModel, self).__init__()
     self.hourdist = DataItem([(i, 0) for i in range(6)])
     self.wdaydist = DataItem([(i, 0) for i in range(7)])
     self.mdaydist = DataItem([(i, 0) for i in range(32)])
     if isinstance(ticks[0], datetime):
         for i in range(len(ticks)):
             ticks[i] = ticks[i].timetuple()
     for tick in ticks:
         self.hourdist[tick.tm_hour / 4] += 1
         self.mdaydist[tick.tm_mday] += 1
         self.wdaydist[tick.tm_wday] += 1
     self.hourdist = norm_v1(self.hourdist)
     self.wdaydist = norm_v1(self.wdaydist)
     self.mdaydist = norm_v1(self.mdaydist)
Exemple #3
0
 def __init__(self, text):
     super(LanguageModel, self).__init__(norm_v1(bgdist(f_tf(text))))