Smart Chunker Engine
Модульный фреймворк для интеллектуального разбиения текста на семантические чанки с богатыми метаданными (русский/английский).
Возможности / Features
- Многоступенчатый пайплайн (нормализация, разбиение, семантика, метаданные)
- Гибкая настройка через config
- Поддержка русского и английского (и других языков при наличии моделей)
- Экспорт в JSON/CSV/Parquet (через chunk_metadata_adapter)
- Простая интеграция в ML/NLP пайплайны, API, CI
Установка / Installation
pip install -r requirements.txt
# или
pip install .
Быстрый старт / Quick Start
from smart_chunker_engine.pipeline import SmartChunkerPipeline
pipeline = SmartChunkerPipeline()
chunks = pipeline.run("Это пример текста для разбиения на чанки.")
for c in chunks:
print(c.text)
Примеры использования / Usage Examples
1. Базовый пример (русский)
from smart_chunker_engine.pipeline import SmartChunkerPipeline
pipeline = SmartChunkerPipeline()
text = "Это пример текста для разбиения на чанки. Каждый чанк будет содержать метаданные."
chunks = pipeline.run(text)
for c in chunks:
print(f"[{c.start}:{c.end}] {c.text}")
2. Кастомные настройки пайплайна
config = {
'split': {'chunk_size': 50},
'boundary': {'window_size': 10, 'threshold': 0.12},
'stats_gate': {'var_thr': 0.1},
'triple_cluster': {'min_cluster': 2},
'tfidf': {'top_n': 100},
'iter_refine': {'lambda_': 0.3, 'max_iter': 2}
}
pipeline = SmartChunkerPipeline(config)
chunks = pipeline.run("Текст для теста с кастомными параметрами.")
3. Экспорт чанков в JSON
from smart_chunker_engine.exporter import export_chunks
export_chunks(chunks, "output.json", format="json")
4. Обработка английского текста
config = {'split': {'chunk_size': 40}, 'spacy_model': 'en_core_web_sm'}
pipeline = SmartChunkerPipeline(config)
text = "This is an example of English text. The chunker works for multiple languages."
chunks = pipeline.run(text)
5. Обработка батча текстов
pipeline = SmartChunkerPipeline({'split': {'chunk_size': 60}})
texts = ["Первый текст для чанкинга.", "Второй текст для примера."]
all_chunks = [pipeline.run(t) for t in texts]
6. Интеграция с pandas (DataFrame)
import pandas as pd
from smart_chunker_engine.pipeline import SmartChunkerPipeline
pipeline = SmartChunkerPipeline()
df = pd.DataFrame({'text': ["Текст 1.", "Текст 2."]})
df['chunks'] = df['text'].apply(lambda t: pipeline.run(t))
Описание основных настроек / Main Config Options
| Этап | Ключ config | Описание параметров |
|---|---|---|
| Split | split | chunk_size, overlap, language, chunk_type |
| Boundary | boundary | window_size, step, threshold, model_name |
| StatsGate | stats_gate | var_thr, ent_thr, gini_thr |
| TripleExtractor | spacy_model | model_name (ru_core_news_md, en_core_web_sm, ...) |
| TripleCluster | triple_cluster | min_cluster, model_name, device, batch_size |
| TfidfLayer | tfidf | top_n |
| Metablock | metablock | threshold, model_name |
| IterativeRefine | iter_refine | lambda_, theta_high, theta_low, epsilon, max_iter, model_name, device |
Пример полного config:
config = {
'split': {'chunk_size': 100, 'overlap': 10, 'language': 'ru'},
'boundary': {'window_size': 15, 'step': 5, 'threshold': 0.13},
'stats_gate': {'var_thr': 0.12, 'ent_thr': 7.5, 'gini_thr': 0.2},
'spacy_model': 'ru_core_news_md',
'triple_cluster': {'min_cluster': 3, 'device': 'cpu'},
'tfidf': {'top_n': 150},
'metablock': {'threshold': 0.22},
'iter_refine': {'lambda_': 0.35, 'theta_high': 0.7, 'theta_low': 0.3, 'epsilon': 0.005, 'max_iter': 3}
}
Документация / Documentation
- COMPONENTS.md — описание всех модулей
- PIPELINE_OVERVIEW.md — архитектура и поток данных
- FAQ.md, HOWTO.md — практические советы
- Примеры: examples/
- Тесты: tests/
License
MIT
Metadata
Release files for smart-chunker-engine 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 | |
|---|---|---|---|---|
| smart_chunker_engine-0.1.0.tar.gz | 50.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| smart_chunker_engine-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 84.1 kB
Release files / smart_chunker_engine-0.1.0.tar.gz
| Download URL | smart_chunker_engine-0.1.0.tar.gz |
|---|---|
| Size | 50.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
493e3fe11bd86e5a3660120090c03e6a5cf29d40b47803173fbfb5f92c7e3382
|
|
BLAKE2b-256 checksum How to use checksums |
a80c404cd9cbbf435c8ec33f6c33194ada56150a6ffbb2f465590806f301e843
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / smart_chunker_engine-0.1.0-py3-none-any.whl
| Download URL | smart_chunker_engine-0.1.0-py3-none-any.whl |
|---|---|
| Size | 33.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdb59733c11facad598aaa08355cbc6491ef00e37897a055d72c20e0caebc81e
|
|
BLAKE2b-256 checksum How to use checksums |
611d1f6ce2fd1a498254f8d7b0437cd77c9f68657d971baedf2fbfc2f8cbf077
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for smart-chunker-engine 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.