Skip to main content

corpus_cluster_explorer

corpus_cluster_explorer — это Python-пакет для загрузки, предобработки и кластеризации структурированных текстовых датасетов.

Пакет поддерживает два основных сценария работы:

  1. Полный пайплайн
    Загрузка структурированного датасета, автоматическое обнаружение текстовых полей, выбор полей для анализа, токенизация корпуса, извлечение биграмм, обучение Word2Vec, оценка качества кластеризации, запуск KMeans и экспорт результатов.

  2. Продолжение работы с токенизированного корпуса
    Загрузка ранее сохранённого токенизированного корпуса в формате JSONL и продолжение анализа сразу с этапа эмбеддингов и кластеризации.


Возможности

  • загрузка структурированных текстовых датасетов:
    • JSONL
    • JSON
    • CSV
    • TSV
  • автоматическое обнаружение текстовых полей
  • предобработка текста:
    • приведение к нижнему регистру
    • удаление ссылок
    • удаление @username
    • удаление хэштегов
    • очистка пунктуации
    • лемматизация русских слов с помощью pymorphy3
  • извлечение биграмм (gensim.Phrases)
  • обучение Word2Vec
  • кластеризация (KMeans)
  • оценка качества (silhouette score)
  • PCA для визуализации
  • экспорт:
    • токенизированного корпуса
    • корпуса с кластерной разметкой

Установка

pip install corpus-cluster-explorer

Быстрый старт

Полный пайплайн

from corpus_cluster_explorer import CorpusExplorer

explorer = CorpusExplorer()

# загрузка данных
explorer.load("data.jsonl")

# посмотреть какие текстовые поля найдены
print(explorer.text_fields)

# выбрать поля
explorer.choose_fields(explorer.text_fields)

# токенизация
explorer.tokenize()

# сохранить при необходимости
explorer.save_tokenized("tokenized.jsonl")

# эмбеддинги + подбор кластеров
explorer.fit_embeddings()
valid_k, scores = explorer.evaluate_clusters()
print(valid_k, scores)

# кластеризация
explorer.cluster(4)

# сохранить результат
explorer.save_clustered("clustered.jsonl")

Продолжение с токенизированного корпуса

from corpus_cluster_explorer import CorpusExplorer

explorer = CorpusExplorer()

explorer.load_tokenized("tokenized.jsonl")

explorer.fit_embeddings()
valid_k, scores = explorer.evaluate_clusters()

explorer.cluster(4)
explorer.save_clustered("clustered.jsonl")

API

Загрузка

explorer.load("data.jsonl")
explorer.text_fields

Выбор полей

explorer.choose_fields(["text"])

или

explorer.choose_fields(explorer.text_fields)

Токенизация

explorer.tokenize()

Статистика

explorer.token_stats()

Кластеризация

explorer.fit_embeddings()
explorer.evaluate_clusters()
explorer.cluster(4)

Сохранение

explorer.save_tokenized("tokenized.jsonl")
explorer.save_clustered("clustered.jsonl")

CLI

corpus-explorer data.jsonl --fields text comments_text --clusters 4

Форматы данных

Tokenized JSONL

  • tokens
  • combined_text
  • field_text_map

Clustered JSONL

  • tokens
  • cluster_ids
  • cluster_labels

Замечания

  • русские слова лемматизируются
  • нерусские токены сохраняются
  • используются только биграммы
  • можно продолжать работу с сохранённого токенизированного корпуса
  • рекомендуется сначала посмотреть explorer.text_fields, затем выбирать поля

Лицензия

MIT

Metadata

Release files for corpus-cluster-explorer 0.1.2

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

Source distribution (sdist)

Source distribution for corpus-cluster-explorer 0.1.2
File Size Uploaded Provenance Actions
corpus_cluster_explorer-0.1.2.tar.gz 11.8 kB Without provenance Details for corpus_cluster_explorer-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for corpus-cluster-explorer 0.1.2
File Interpreter ABI Platform Actions
corpus_cluster_explorer-0.1.2-py3-none-any.whl Python 3 none any Details for corpus_cluster_explorer-0.1.2-py3-none-any.whl

Total release size: 25.5 kB

Release files / corpus_cluster_explorer-0.1.2.tar.gz

Download URL corpus_cluster_explorer-0.1.2.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3a9cff6909624676194d09a0c667508181af6cac93bea822af731fa2ee60c460
BLAKE2b-256 checksum
How to use checksums
8de9bd3b9f47252dc4f5025f94b12bf86e39944dbfd398a3bae93af1aaeb527a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / corpus_cluster_explorer-0.1.2-py3-none-any.whl

Download URL corpus_cluster_explorer-0.1.2-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bce73e6164072d50a8a771fb1e67e70ffff727ee1e872b754f8a04a50b9828c
BLAKE2b-256 checksum
How to use checksums
0db8308a7d9ddbc0afaee5e1938fd98930cd86127bd5bcb72e0976b4d501dc45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for corpus-cluster-explorer 0.1.2

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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

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