in the collection of Beauty station , we need to keyword Word segmentation, the final use of Python's stuttering word segmentation method.
Chinese word segmentation is a basic work in Chinese text processing, and stuttering participle is used for Chinese word segmentation. Its basic implementation principle has three points:
Efficient word-map scanning based on trie tree structure to generate a directed acyclic graph (DAG) consisting of all possible words of Chinese characters in a sentence
Using dynamic programming to find the maximum probability path, the maximum segmentation combination based on word frequency is found.
For the non-login words, the hmm model based on Chinese characters ' lexical ability is adopted, and the Viterbi algorithm is used.
Installation (Linux environment)
Download The toolkit , unzip it into the directory, run: Python setup.py install
Mode
Default mode, try to cut the sentence most accurately, suitable for text analysis
Full mode, the sentence all can be the word words are scanned out, suitable for the search engine
Interface
650) this.width=650; "style=" vertical-align:middle; "src="/>
Instance
650) this.width=650; "style=" vertical-align:middle; "alt=" Copy Code "src="/>
Hljs gradle code 650) this.width=650; "alt=" Copy Code "src=" Http://yangjiyue.iteye.com/images/icon_copy.gif "/>
<span style="margin:0px; padding:0px; " >#! -*-coding:utf-<span class="Hljs-number" style= "margin:0px; padding:0px; Color:rgb (0, 102, 102); " >8</span>-*-
<span class="Hljs-keyword" style= "margin:0px; padding:0px; Color:rgb (0, 0, 136); " >import</span> Jieba
-
Seg_list = jieba.cut (<span class= style = "Margin: 0px; padding: 0px; color: rgb (0, 136, 0);" > "I came to Tsinghua University in Beijing" </span>, cut_all = <span class= "Hljs-keyword" style= >True</span>)
-
<span class= style= "margin: 0px; padding: 0px; color: rgb (0, 0, 136); " >print</span> <span class= "hljs-string" style= "Margin: 0px; padding: 0px; color: rgb (0, 136, 0);" > "Full mode:" </span>, <span class= style= "Margin: 0px; padding: 0px; color: rgb (0, 136, 0); " > ' ' </span>.<span class= style= "Margin: 0px; padding: 0px; color: rgb (0, 0, 136); " >join</span> (seg_list)
Seg_list = Jieba.cut (<span class=" hljs-string" style= "margin:0px"; padding:0px; Color:rgb (0, 136, 0); " >"I came to Tsinghua University in Beijing"</span>)
<span class="Hljs-keyword" style= "margin:0px; padding:0px; Color:rgb (0, 0, 136); " >print</span> <span class="hljs-string" style= "margin:0px; padding:0px; Color:rgb (0, 136, 0); " >"Default Mode:"</span>, <span class="hljs-string" style= "margin:0px; padding:0px; Color:rgb (0, 136, 0); " >"</span>.<span class=" Hljs-keyword " style="margin:0px; padding:0px; Color:rgb (0, 0, 136); " >join</span> (seg_list) </span>
Python Chinese word breaker with stutter participle for Python