Skip to main content

Parse a corpus, manage it and extract themes from a corpus.

Project description

theme-extractor

Python toolkit to compare theme/topic extraction strategies on the same corpus, with:

  • one unified CLI
  • one unified JSON output schema
  • offline-first execution options
  • Elasticsearch/OpenSearch backend support

Why this project

theme-extractor helps you answer one practical question: "Which extraction strategy works best for my corpus and constraints?"

It lets you run baseline lexical methods, embedding-based methods, and LLM-assisted methods with consistent outputs for easier comparison.

Core Commands

  • theme-extractor ingest
  • theme-extractor extract
  • theme-extractor benchmark
  • theme-extractor evaluate
  • theme-extractor report
  • theme-extractor doctor

Quickstart

Prerequisite: start one backend first (local Docker guide: /howto/docker-local.md).

uv sync --group elasticsearch
uv run theme-extractor doctor --output data/out/doctor.json
uv run theme-extractor ingest --input data/raw --output data/out/ingest.json
uv run python docker/index_corpus.py \
  --input data/raw \
  --backend-url http://localhost:9200 \
  --index theme_extractor \
  --cleaning-options all \
  --default-stopwords \
  --manual-stopwords "de,le,la,the,and,of" \
  --reset-index
uv run theme-extractor benchmark \
  --methods baseline_tfidf,terms,significant_terms,keybert,bertopic \
  --backend elasticsearch \
  --backend-url http://localhost:9200 \
  --index theme_extractor \
  --focus both \
  --output data/out/benchmark.json
uv run theme-extractor evaluate \
  --input data/out/benchmark.json \
  --output data/out/evaluation.json
uv run theme-extractor report \
  --input data/out/benchmark.json \
  --output data/out/report_benchmark.md

ingest generates a local JSON QA payload; extraction methods query backend indexes. Use docker/index_corpus.py to index cleaned/filtered text into Elasticsearch/OpenSearch.

Run significant_text separately with --agg-field content (see /howto/benchmark.md).

Methods Available

  • Baselines:
    • baseline_tfidf
    • terms
    • significant_terms
    • significant_text
  • Semantic:
    • keybert
    • bertopic (embedding on/off, reduction none/svd/nmf/umap, clustering kmeans/hdbscan)
  • Generative:
    • llm (offline fallback behavior supported)

What You Get

  • Unified extraction schema:
    • topic-first output (topics)
    • optional document-topic links (document_topics)
    • execution notes and metadata (notes, metadata)
  • Benchmark output:
    • per-method outputs
    • comparison block
  • Quantitative proxies via evaluate:
    • topic coherence proxy
    • inter-topic diversity
    • run-to-run stability

Documentation Map (How-To)

Detailed operations are intentionally kept in /howto:

Sphinx documentation is available under /docs (includes README, how-to pages, and API docstrings).

Build locally:

uv run sphinx-build -b html docs docs/_build/html

Configuration

Use .env.template as bootstrap:

cp .env.template .env
set -a; source .env; set +a

Important variable groups:

  • backend/runtime (THEME_EXTRACTOR_BACKEND*, THEME_EXTRACTOR_PROXY_URL)
  • ingestion stopwords (THEME_EXTRACTOR_DEFAULT_STOPWORDS_ENABLED, THEME_EXTRACTOR_AUTO_STOPWORDS_*)
  • PDF OCR fallback (THEME_EXTRACTOR_PDF_OCR_*) for scanned PDFs
  • .msg extraction (THEME_EXTRACTOR_MSG_*) for metadata and attachment policy
  • local model resolution (THEME_EXTRACTOR_LOCAL_MODELS_DIR)
  • BERTopic embedding cache (THEME_EXTRACTOR_BERTOPIC_EMBEDDING_CACHE_*)

Project Governance

Community Standards

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

theme_extractor-0.1.1.tar.gz (47.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

theme_extractor-0.1.1-py3-none-any.whl (60.1 kB view details)

Uploaded Python 3

File details

Details for the file theme_extractor-0.1.1.tar.gz.

File metadata

  • Download URL: theme_extractor-0.1.1.tar.gz
  • Upload date:
  • Size: 47.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for theme_extractor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b5211531a3cc1deb2ed2d89311785d4182d085ac6d60fa1c9f74d330b017c100
MD5 90745a2da92125d956dd524d10d1509e
BLAKE2b-256 f32448f5917f9c8724099b84aa525d60f58e7f9fc827766cdefb7e8857516873

See more details on using hashes here.

Provenance

The following attestation bundles were made for theme_extractor-0.1.1.tar.gz:

Publisher: release.yml on Guillaume-Lombardo/theme-extractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file theme_extractor-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for theme_extractor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ff047104e17db0379d253744ca897ef11df0e567777ac16f2e7a29b5c65dbc63
MD5 7790caf0cc05bc8d8dff3f1bdeddc843
BLAKE2b-256 4944bd752a915b76653d6786b4378d826b534372aa2f42014825900176d05e79

See more details on using hashes here.

Provenance

The following attestation bundles were made for theme_extractor-0.1.1-py3-none-any.whl:

Publisher: release.yml on Guillaume-Lombardo/theme-extractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page