Jina Segmenter
一个基于 Jina AI API 的智能文本分段工具。它能够智能地将长文本分割成合适大小的片段,同时保持语义的完整性。
特性
- 智能文本分段,保持语义完整性
- 自动计算和优化分片大小
- 支持自定义最大分片大小
- 返回每个分片的 token 数量
- 简单易用的 API
安装
pip install jina-segmenter
使用方法
首先,你需要设置 Jina AI 的 API key:
import os
os.environ['JINA_API_KEY'] = 'your_jina_api_key'
然后你就可以使用分段功能:
from jina_segmenter import segment_text
text = "你的长文本..."
chunks = segment_text(text) # 默认最大分片大小为 1500 tokens
# 查看分片结果
for i, chunk in enumerate(chunks, 1):
print(f"片段 {i} (tokens: {chunk['tokens']}):")
print(chunk['text'])
print("-" * 30)
你也可以自定义最大分片大小:
chunks = segment_text(text, max_chunk_size=1000)
获取 API Key
- 访问 Jina AI
- 注册并登录你的账号
- 在控制台中创建新的 API key
依赖
- Python >= 3.6
- requests >= 2.31.0
许可证
MIT License
作者
WSY (wangshuyue@gmail.com)
Metadata
Release files for jina-segmenter 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jina_segmenter-0.1.0.tar.gz | 3.9 kB | Without provenance | Details for jina_segmenter-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jina_segmenter-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for jina_segmenter-0.1.0-py3-none-any.whl |
Total release size: 8.3 kB
Release files / jina_segmenter-0.1.0.tar.gz
| Download URL | jina_segmenter-0.1.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6ed6fd18ad9c8b4d939cc9fcac899df8261ebc92c0b4f2e6bed2f73fad2e97c
|
|
BLAKE2b-256 checksum How to use checksums |
d9837ea286948794bb049a73cbc4da798bed685236537c9ba782ae0052139333
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.2
|
Release files / jina_segmenter-0.1.0-py3-none-any.whl
| Download URL | jina_segmenter-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
84603e4b9f3fd4c8b24f6a626605474f1d9d1ff022caad482a4fb502a0b733f8
|
|
BLAKE2b-256 checksum How to use checksums |
6c68b821c602296cec211b9f296089c80e86060e36d42e2f42cb0700b982354b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.2
|
Security for jina-segmenter 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.