Skip to main content

Fork yanyiwu/cppjieba: "结巴" 中文分词的 C++ 版本 包装,性能接近。

Install

$ pip install cppjieba
# or
$ git clone https://github.com/hscspring/cppjieba.git
$ cd cppjieba
$ pip install .
$ # or :
$ python setup.py install

Usage

from cppjieba import Jieba

jb = Jieba()
# 可以指定自定义路径:
# dict_path: 分词词典路径
# hmm_path: hmm 模型路径
# user_dict_path: 用户自定义词典路径
# idf_path: idf 词典路径
# stop_words_path: 停用词路径
# Example: jb = Jieba(user_dict_path="path/to/your_dict")

s = "他来到了网易杭研大厦"
result = jb.cut(s)
print("/".join(result))
# 他/来到/了/网易/杭研/大厦

result = jb.cut(s, hmm=False)
print("/".join(result))
# 他/来到/了/网易/杭/研/大厦

s = "我来到北京清华大学"
result = jb.cut_all(s)
print(result)
# ['我', '来到', '北京', '清华', '清华大学', '华大', '大学']

s = "小明硕士毕业于中国科学院计算所,后在日本京都大学深造"
result = jb.cut_for_search(s)
print(result)
# ['小明', '硕士', '毕业', '于', '中国', '科学', '学院', '科学院', '中国科学院', '计算', '计算所', ',', '后', '在', '日本', '京都', '大学', '日本京都大学', '深造']

s = "我是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。"
result = jb.pseg(s)
print(result)
# [('我', 'r'), ('是', 'v'), ('拖拉机', 'n'), ('学院', 'n'), ('手扶拖拉机', 'n'), ('专业', 'n'), ('的', 'uj'), ('。', 'x'), ('不用', 'v'), ('多久', 'm'), (',', 'x'), ('我', 'r'), ('就', 'd'), ('会', 'v'), ('升职', 'v'), ('加薪', 'nr'), (',', 'x'), ('当上', 't'), ('CEO', 'eng'), (',', 'x'), ('走上', 'v'), ('人生', 'n'), ('巅峰', 'n'), ('。', 'x')]

result = jb.extract(s)
print(result)
# [('CEO', 11.739204307083542), ('升职', 10.8561552143), ('加薪', 10.642581114), ('手扶拖拉机', 10.0088573539), ('巅峰', 9.49395840471)]

Release files for cppjieba 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cppjieba 0.1.1
File Size Uploaded
cppjieba-0.1.1.tar.gz 5.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for cppjieba 0.1.1
File Interpreter ABI Platform
cppjieba-0.1.1-cp37-cp37m-macosx_10_14_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64 Details

Total release size: 10.1 MB

Release files / cppjieba-0.1.1.tar.gz

Download URL cppjieba-0.1.1.tar.gz
Size 5.0 MB
Tags Source
SHA-256 checksum
How to use checksums
9af08d587416abb3bbb78ba55c106ebb65cda39e6a2cbd3dca0531c71f6e7c71
BLAKE2b-256 checksum
How to use checksums
808513675cc872b4e90d2839a92cde0d8748285a9284120473fdf0f9a06417cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / cppjieba-0.1.1-cp37-cp37m-macosx_10_14_x86_64.whl

Download URL cppjieba-0.1.1-cp37-cp37m-macosx_10_14_x86_64.whl
Size 5.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
c8e3333b625e794c307e69e48ff5ce77326d6f31413106afb1255164b8aff92f
BLAKE2b-256 checksum
How to use checksums
8dd80e57fd5e42a2d4e6dc6fc0bda5c08dea3a9455090f399ba5922d76b699c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page