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
评论列表
文章目录