Example #1
0
    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()
Example #2
0
    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()
Example #3
0
    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 + "*")
Example #4
0
def split_pinyin(text):
    """docstring for split_pinyin"""

    return split_words(Pinyin.t(text))
Example #5
0
def split_pinyin(text):
    """docstring for split_pinyin"""
    
    return split_words(Pinyin.t(text))