Python Chinese Word Segmentation: uses the jieba word segmentation to perform word segmentation on python,

Source: Internet
Author: User

Python Chinese Word Segmentation: uses the jieba word segmentation to perform word segmentation on python,

When collecting the beauty site, you need to perform word segmentation on the keywords. The final method is python's jieba word segmentation.

Chinese Word Segmentation is a basic task of Chinese text processing. It is used for Chinese word segmentation. The basic implementation principle is as follows:

Installation (Linux)

Download the toolkit, decompress the package, go to the directory, and run: python setup. py install

 

Mode

 

Interface

  • The component only provides the jieba. cut Method for word segmentation.
  • The cut method accepts two input parameters:
    • The first parameter is the string to be segmented.
    • The cut_all parameter is used to control the word segmentation mode.
  • The string to be segmented can be a gbk string, UTF-8 string, or unicode string.
  • Jieba. the structure returned by cut is an iterative generator. You can use the for loop to obtain each word (unicode) obtained after word segmentation. You can also use list (jieba. cut (...)) convert to list
  • Seg = jieba. cut ("http://www.gg4493.cn /"):

 

Instance

#! -*-Coding: UTF-8-*-import jiebaseg_list = jieba. cut ("I came to Beijing Tsinghua University", cut_all = True) print "Full Mode :",''. join (seg_list) seg_list = jieba. cut ("I came to Beijing Tsinghua University") print "Default Mode :",''. join (seg_list)

Result

 

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.