您当前的位置: 首页 >  彭世瑜 Python

Python:使用pyhanlp 进行分词

彭世瑜 发布时间:2019-07-11 17:32:56 ,浏览量:4

pyhanlp调用java实现的HanLP接口进行分词

安装

pip install pyhanlp

pyhanlp: https://github.com/hankcs/pyhanlp HanLP: https://github.com/hankcs/HanLP

代码示例

# -*- coding: utf-8 -*-

from pyhanlp import HanLP

document = "你好,欢迎在Python中调用HanLP的API"

# 分词
print(HanLP.segment(document))
"""
[你好/vl, ,/w, 欢迎/v, 在/p, Python/nx, 中/f, 调用/v, HanLP/nx, 的/ude1, API/nx]
"""

# 关键词提取
print(HanLP.extractKeyword(document, 2))
# [中, 调用]

# 自动摘要
print(HanLP.extractSummary(document, 3))
# [欢迎在Python中调用HanLP的API]
关注
打赏
1688896170
查看更多评论

彭世瑜

暂无认证

  • 4浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0542s