Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to Segmentation the text by jieba

Shulou Source: shulou.com Published: 2022-06-01 05:02:37 10月03日 Update

This article mainly introduces "jieba how to divide text". In daily operation, I believe many people have doubts about jieba how to divide text. Xiaobian consulted all kinds of materials and sorted out simple and easy operation methods. I hope to help you answer the doubts of "jieba how to divide text"! Next, please follow the small series to learn together!

Jieba library is a powerful Chinese word segmentation library, for Chinese word segmentation.(pip install jieba)

Jieba has three word segmentation modes: exact mode, full mode and search engine mode. Here are the characteristics of the three modes:

Precision mode: The sentence is separated most accurately, suitable for text analysis.

2, full mode: all the words in the sentence can be cut into words, fast, but ambiguous.

3. Search engine mode: on the basis of accurate mode, segment long words again to improve recall rate and

Word segmentation suitable for search engines

The code is as follows:

import jieba

words = 'The Data Science Community Team is dedicated to sharing knowledge about data science programming languages and algorithms'

#precise pattern print("/".join(jieba.lcut(words)))

#full mode print("/".join(jieba.lcut(words,cut_all=True)))

#search engine pattern print("/".join(jieba.lcut_for_search(words, )))

The results were as follows:

#Text segmentation for precise mode Chinese reading

Data/Science/Public/Number/Team/Dedicated/Shared/About/Data/Science/Programming Language/And/Algorithms/etc/Knowledge

#Full mode lists all text that can be words

Data/Science/Public/Number/Team/Commitment/Commitment/Share/About/Data/Science/Programming/Programming Language/And/Algorithms/etc/Knowledge

#Search engine mode strengthens segmentation of long words and improves search recall

Data/Science/Public/Number/Team/Commitment/Commitment/Sharing/About/Data/Science/Programming/Languages/Programming Languages/And/Algorithms/etc/Knowledge

At this point, the study of "jieba how to divide the text" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Pattern data science text precision language search programming engine search engine knowledge public team algorithm programming language commitment learning sentence more Chinese Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology Microsoft Docker NVidia