Skip to content

MrDuoDuo2/Hanlp-split

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HanLP Split Engine

一个基于 HanLP 的 Python 文本拆分引擎,输入文本,输出 JSON。

安装

项目代码本身不需要安装,推荐只安装第三方依赖,并通过 PYTHONPATH 运行。

python -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
python -m pip install -r requirements.txt

命令行使用

在项目根目录执行:

PYTHONPATH=. python main.py --text "今天天气很好。我们去公园散步吧!"

或使用模块方式:

PYTHONPATH=. python -m hanlp_split --text "今天天气很好。我们去公园散步吧!"

也可以通过标准输入传入文本:

echo "今天天气很好。我们去公园散步吧!" | PYTHONPATH=. python main.py

输出示例

{
  "text": "今天天气很好。我们去公园散步吧!",
  "sentence_count": 2,
  "sentences": [
    {
      "index": 0,
      "text": "今天天气很好。",
      "start": 0,
      "end": 7,
      "length": 7
    },
    {
      "index": 1,
      "text": "我们去公园散步吧!",
      "start": 7,
      "end": 16,
      "length": 9
    }
  ]
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages