# *-*coding=utf8*-*'''
Created on 2018年12月8日
@author: admin
'''#-*- coding:utf-8 -*-import jieba
jieba.load_userdict("./dict.txt")
word_list = jieba.cut("今天去远足吗?要不咱们换个地方吧!园小园怎么样?没问题小豆芽")print("|".join(word_list))
TEST 3
# *-*coding=utf8*-*'''
Created on 2018年12月8日
@author: admin
'''import jieba.analyse as al
content =open("./topk.txt","rb").read()
word_topk = al.extract_tags(content,topK=4)print("|".join(word_topk))
TEST 4
# *-*coding=utf8*-*'''
Created on 2018年12月8日
@author: admin
'''import jieba.posseg as pseg
words = pseg.cut("青岛北京是不错的地方")for word in words:print(word.word,word.flag)
TEST 5
# *-*coding=utf8*-*'''
Created on 2018年12月8日
@author: admin
'''import jieba
#开启并行分词模式,参数为参与并行分词的进程数#jieba.enable_parallel(2)#关闭并行分词#jieba.disable_parallel()
content =open("./topk.txt","rb").read()
words = jieba.cut(content)print("|".join(words))
TEST 6
# *-*coding=utf8*-*'''
Created on 2018年12月8日
@author: admin
'''#-*- coding:utf-8 -*-import jieba
jieba.set_dictionary("./dict.txt")
content =open("./topk.txt","rb").read()
words = jieba.cut(content)print("|".join(words))
TEST 7
# *-*coding=utf8*-*'''
Created on 2018年12月8日
@author: admin
'''import jieba
result = jieba.tokenize(u'今天天气真好。亲爱的,我们去远足吧!')for token in result:print("word %s\t\t start: %d \t\t end:%d"%(token[0],token[1],token[2]))