word_segment.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:http_server 作者: chenguolin 项目源码 文件源码
def cut_with_weight(self, sentence):
        """
        Cut word string with weight

        @sentence: word string

        return list or None
        ["word1`weight1", "word2`weight2" ...]
        """
        try:
            top_k = 2147483647
            seg_list = jieba.analyse.extract_tags(sentence, topK=top_k, withWeight=True)
            return [item[0].encode('utf-8')+'`'+str(item[1]) for item in seg_list]
        except Exception,e:
            logger.error('cut sentence:[%s] exception:[%s]' % (sentence, str(e)))
            return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号