ustbclearwang 2020-05-09
今日一言:“从来不是让你把一次考试当成人生成败的赌注,
?????只是想让你在足够年轻的时候体会一次全力以赴。”
??????????????????——《请回答1988》
jieba库是一款优秀的 Python 第三方中文分词库,jieba 支持三种分词模式:精确模式、全模式和搜索引擎模式,下面是三种模式的特点。
C:\Users\20152>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jiebaLooking in indexes: https://pypi.tuna.tsinghua.edu.cn/simpleCollecting jieba Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c6/cb/18eeb235f833b726522d7ebed54f2278ce28ba9438e3135ab0278d9792a2/jieba-0.42.1.tar.gz (19.2 MB) |████████████████████████████████| 19.2 MB 373 kB/sInstalling collected packages: jieba Running setup.py install for jieba ... doneSuccessfully installed jieba-0.42.1
import jiebavar_str = "小鱼爱吃鱼,非偏振光有完全偏振光和部分偏振光"print(jieba.lcut(var_str))print(jieba.lcut(var_str, cut_all=True))print(jieba.lcut_for_search(var_str))
C:\Users\20152\AppData\Local\Programs\Python\Python36\python.exe C:/Users/20152/PycharmProjects/cvTest/venv/temp.pyBuilding prefix dict from the default dictionary ...Loading model from cache C:\Users\20152\AppData\Local\Temp\jieba.cacheLoading model cost 0.656 seconds.Prefix dict has been built successfully.[‘小鱼‘, ‘爱吃鱼‘, ‘,‘, ‘非‘, ‘偏振光‘, ‘有‘, ‘完全‘, ‘偏振光‘, ‘和‘, ‘部分‘, ‘偏振光‘][‘小鱼‘, ‘爱吃鱼‘, ‘,‘, ‘非‘, ‘偏振‘, ‘偏振光‘, ‘有‘, ‘完全‘, ‘偏振‘, ‘偏振光‘, ‘和‘, ‘部分‘, ‘偏振‘, ‘偏振光‘][‘小鱼‘, ‘爱吃鱼‘, ‘,‘, ‘非‘, ‘偏振‘, ‘偏振光‘, ‘有‘, ‘完全‘, ‘偏振‘, ‘偏振光‘, ‘和‘, ‘部分‘, ‘偏振‘, ‘偏振光‘]Process finished with exit code 0