cwsharp-python
Python中文分词库,支持自定义词典和多种分词模式。
特点
-
支持多种分词算法。
-
MMSegTokenizer
- 基于字典的分词算法,支持中英混合词组,中文分词准确率高。 -
BigramTokenizer
- 二元分词,支持英文、数字。
-
-
自定义字典,支持中英文混合。
-
兼容Python 2x/3x。
安装
-
easy_install cwsharp
或者pipe install cwsharp
-
pip3 install cwsharp
for Python 3
快速入门
import cwsharp
for token in cwsharp.tokenize(u"你好世界!abc"):
print(token.text)
MMSegTokenizer 分词
from cwsharp.tokenizer import MMSegTokenizer
tokenizer = MMSegTokenizer()
for token in tokenizer.Tokenize(u"你好世界!abc"):
print(token.text)
BigramTokenizer 分词
from cwsharp.tokenizer import BigramTokenizer
tokenizer = MMSegTokenizer()
for token in tokenizer.Tokenize(u"你好世界!abc"):
print(token.text)