def input(self, ml): count = 0 for m in ml: if self._inqueue(m): count += 1 logger.info("Input %d new message", count) self.log("Input %d new message" % count)
def load_weight(self, fn = None): if fn is None: fn = 'conf/weights.json' try: self.feature_weight = json.loads(open(fn, 'r').read()) self.feature_name = self.feature_weight.keys() logger.info("Loaded weights: %s", self.feature_weight) except IOError: logger.warning("No '%s' weights config file, use empty setting.", fn) self.feature_weight = {} self.feature_name = self.feature_weight.keys()
def load_weight(self, fn=None): if fn is None: fn = 'conf/weights.json' try: self.feature_weight = json.loads(open(fn, 'r').read()) self.feature_name = self.feature_weight.keys() logger.info("Loaded weights: %s", self.feature_weight) except IOError: logger.warning("No '%s' weights config file, use empty setting.", fn) self.feature_weight = {} self.feature_name = self.feature_weight.keys()
def input(self, channel = None): if channel: ml = self._home_timeline(channel) else: ml = snstype.MessageList() for chn in self.sp: ml.extend(self._home_timeline(chn)) count = 0 for m in ml: if self._inqueue(m): count += 1 logger.info("Input %d new message", count) self.log("Input %d new message" % count)
def input(self, channel=None): if channel: ml = self._home_timeline(channel) else: ml = snstype.MessageList() for chn in self.sp: ml.extend(self._home_timeline(chn)) count = 0 for m in ml: if self._inqueue(m): count += 1 logger.info("Input %d new message", count) self.log("Input %d new message" % count) return "Input %s new messages" % count
def reweight_all(self, younger_than = 86400): begin = self.time() cur = self.con.cursor() try: latest_time = int(self.time() - younger_than) r = cur.execute(''' SELECT id from msg WHERE time >= ? ''', (latest_time, )) for m in r: self.reweight(m[0]) except Exception, e: logger.warning("Catch exception: %s", e) return False end = self.time() logger.info("Reweight done. Time elapsed: %.2f", end - begin) return True def _dump2pickle(self, fn_pickle): # dump all to pickle format cur = self.con.cursor() r = cur.execute(''' SELECT id,time,userid,username,text,pyobj,flag FROM msg ''') message_list = snstype.MessageList() for m in r: obj = self._str2pyobj(m[5]) obj.msg_id = m[0] obj.flag = m[6] message_list.append(obj) r = cur.execute('''
* lc = load_config * sc = save_config * lsc = list_channel * lsp = list_platform * newc = new_channel * addc = add_channel * clc = clear_channel * auth = auth * ht = home_timeline * up = update * re = reply * fwd = forward * lk = like * ulk = unlike Tutorial of SNSCLI: * https://github.com/hupili/snsapi/wiki/Tutorial-of-snscli """ if __name__ == '__main__': #==== default initialization one may like ==== print helpdoc load_config() list_channel() auth() logger.info("Ready to drop into the interactive shell of SNSCLI!") import code code.interact(local=locals())
def load_weight(self, fn=None): if fn is None: fn = 'conf/weights.json' self.feature_weight = json.loads(open(fn, 'r').read()) self.feature_name = self.feature_weight.keys() logger.info("Loaded weights: %s", self.feature_weight)
def load_weight(self, fn = None): if fn is None: fn = 'conf/weights.json' self.feature_weight = json.loads(open(fn, 'r').read()) self.feature_name = self.feature_weight.keys() logger.info("Loaded weights: %s", self.feature_weight)
begin = self.time() cur = self.con.cursor() try: latest_time = int(self.time() - younger_than) r = cur.execute( ''' SELECT id from msg WHERE time >= ? ''', (latest_time, )) for m in r: self.reweight(m[0]) except Exception, e: logger.warning("Catch exception: %s", e) return False end = self.time() logger.info("Reweight done. Time elapsed: %.2f", end - begin) return True def _dump2pickle(self, fn_pickle): # dump all to pickle format cur = self.con.cursor() r = cur.execute(''' SELECT id,time,userid,username,text,pyobj,flag FROM msg ''') message_list = snstype.MessageList() for m in r: obj = self._str2pyobj(m[5]) obj.msg_id = m[0] obj.flag = m[6] message_list.append(obj) r = cur.execute('''