Python Chinese participle, using stuttering participle to the python participle

Source: Internet
Author: User

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:

    1. 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

    2. Using dynamic programming to find the maximum probability path, the maximum segmentation combination based on word frequency is found.

    3. 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

    1. Default mode, try to cut the sentence most accurately, suitable for text analysis

    2. Full mode, the sentence all can be the word words are scanned out, suitable for the search engine

Interface

    • component only provides Jieba.cut method for word breakers

    • Span style= "margin:0px;padding:0px;" The >cut method accepts two input parameters:

      • /ul>
      • jieba.cut is an iterative generator, and you can use a for loop to get each word (Unicode) that is obtained after a word breaker, You can also use list (Jieba.cut (...)) Convert to list  

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 "/>

  1. <span style="margin:0px; padding:0px; " >#! -*-coding:utf-<span class="Hljs-number" style= "margin:0px; padding:0px; Color:rgb (0, 102, 102); " >8</span>-*-

  2. <span class="Hljs-keyword" style= "margin:0px; padding:0px; Color:rgb (0, 0, 136); " >import</span> Jieba

  3. 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>)   

  4. <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)   

  5. 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>)

  6. <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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.