def save_prefix_index(self): """docstring for save_prefix_index""" words = [] words.append(self.title.lower()) pipe = util.redis.pipeline() pipe.sadd(mk_sets_key(self.name, self.title), self.id) if util.pinyin_match: pinyin = Pinyin.t(self.title.lower(), "") words += pinyin pipe.sadd(mk_sets_key(self.name, pinyin), self.id) key = mk_complete_key(self.name) for word in words: for i in range(0, len(word)): prefix = word[0:i] pipe.zadd(key, prefix, 0) pipe.zadd(key, word + "*", 0) # commit pipe.execute()
def save_prefix_index(self): """docstring for save_prefix_index""" words = [] words.append(self.title.lower()) redis.sadd(mk_sets_key(self.name, self.title), self.id) if config.pinyin_match: pinyin = Pinyin.t(self.title.lower(), "") words += pinyin redis.sadd(mk_sets_key(self.name, pinyin), self.id) key = mk_complete_key(self.name) for word in words: for i in range(0, len(word)): prefix = word[0:i] redis.zadd(key, 0, prefix) redis.zadd(key, 0, word + "*")
def split_pinyin(text): """docstring for split_pinyin""" return split_words(Pinyin.t(text))