# himathx/lk-hansard-topic-modeling architecture

> Architecture diagram of the GitHub repository himathx/lk-hansard-topic-modeling, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/himathx/lk-hansard-topic-modeling
- Repository: https://github.com/himathx/lk-hansard-topic-modeling

## Overview

LK Hansard Topic Modeling is a research workflow for turning Sri Lankan parliamentary Hansard text into speech-level records, multilingual embeddings, micro-topics, and 30 macro-topics, then evaluating and publishing the results. The README documents the main stage sequence and major capabilities; modeling and publishing implementations are not present in the supplied tree, so those nodes use only the existing modeling directory or a null path. Edges reflect documented workflow or visible calls; unsampled implementation details are not inferred.

Main entry points: [`src/evaluation/run_evaluation.py`](https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/evaluation/run_evaluation.py) (Evaluation runner), [`artifacts/final_v14`](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/artifacts/final_v14) (Topic assignments), [`src/ingestion/build_speech_corpus.py`](https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/ingestion/build_speech_corpus.py) (Speech corpus builder), [`src/modeling`](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/src/modeling) (Multilingual embeddings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Corpus ingestion"]
  node_download["Hansard downloader"]
  node_markdown["Hansard Markdown"]
  node_corpus["Speech corpus builder"]
  node_speeches["Speech-level corpus"]
end

subgraph group_model["Topic modeling"]
  node_embeddings["Multilingual embeddings"]
  node_micro["Micro-topic discovery"]
  node_macro["Macro-topic aggregation"]
  node_model_outputs["Topic assignments"]
end

subgraph group_evaluate["Evaluation"]
  node_gold["Gold evaluation labels"]
  node_classification["Classification metrics"]
  node_quality["Topic quality metrics"]
  node_evaluation_runner["Evaluation runner<br/>[run_evaluation.py]"]
  node_extraction_audit["Extraction audit"]
  node_audit_results["Evaluation results"]
end

subgraph group_publish["Publication"]
  node_dataset[("Hugging Face dataset")]
  node_dashboard["Interactive dashboard"]
end

node_parliament(("Hansard source"))
node_reviewer(("Researchers and reviewers"))

node_parliament -->|"provides PDFs"| node_download
node_markdown -->|"extracts speeches"| node_corpus
node_corpus -->|"builds corpus"| node_speeches
node_speeches -->|"generates embeddings"| node_embeddings
node_embeddings -->|"discovers topics"| node_micro
node_micro -->|"aggregates topics"| node_macro
node_macro -->|"produces assignments"| node_model_outputs
node_gold -->|"supplies labels"| node_evaluation_runner
node_model_outputs -->|"supplies assignments"| node_evaluation_runner
node_evaluation_runner -->|"calls metrics"| node_classification
node_evaluation_runner -->|"calls metrics"| node_quality
node_evaluation_runner -->|"writes reports"| node_audit_results
node_reviewer -->|"audits extraction"| node_extraction_audit
node_model_outputs -->|"publishes dataset"| node_dataset
node_model_outputs -->|"supports dashboard"| node_dashboard
node_dataset -->|"serves dataset"| node_reviewer
node_dashboard -->|"presents results"| node_reviewer

click node_download "https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/ingestion/hansard_download.py"
click node_markdown "https://github.com/himathx/lk-hansard-topic-modeling/tree/main/data/extracted-markdown"
click node_corpus "https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/ingestion/build_speech_corpus.py"
click node_speeches "https://github.com/himathx/lk-hansard-topic-modeling/tree/main/artifacts/final_v14"
click node_embeddings "https://github.com/himathx/lk-hansard-topic-modeling/tree/main/src/modeling"
click node_micro "https://github.com/himathx/lk-hansard-topic-modeling/tree/main/src/modeling"
click node_macro "https://github.com/himathx/lk-hansard-topic-modeling/tree/main/src/modeling"
click node_model_outputs "https://github.com/himathx/lk-hansard-topic-modeling/tree/main/artifacts/final_v14"
click node_gold "https://github.com/himathx/lk-hansard-topic-modeling/tree/main/data/evaluation"
click node_classification "https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/evaluation/classification_metrics.py"
click node_quality "https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/evaluation/topic_quality_metrics.py"
click node_evaluation_runner "https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/evaluation/run_evaluation.py"
click node_extraction_audit "https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/evaluation/extraction_audit.py"
click node_audit_results "https://github.com/himathx/lk-hansard-topic-modeling/tree/main/artifacts/evaluation"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_download,node_markdown,node_corpus,node_speeches,node_reviewer toneBlue
class node_embeddings,node_micro,node_macro,node_model_outputs toneAmber
class node_gold,node_classification,node_quality,node_evaluation_runner,node_extraction_audit,node_audit_results toneMint
class node_dataset,node_dashboard toneRose
class node_parliament toneIndigo
```

## Components

### Corpus ingestion

- [Hansard downloader](https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/ingestion/hansard_download.py): `src/ingestion/hansard_download.py`
- [Hansard Markdown](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/data/extracted-markdown): `data/extracted-markdown`
- [Speech corpus builder](https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/ingestion/build_speech_corpus.py): `src/ingestion/build_speech_corpus.py`
- [Speech-level corpus](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/artifacts/final_v14): `artifacts/final_v14`

### Topic modeling

- [Multilingual embeddings](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/src/modeling): `src/modeling`
- [Micro-topic discovery](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/src/modeling): `src/modeling`
- [Macro-topic aggregation](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/src/modeling): `src/modeling`
- [Topic assignments](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/artifacts/final_v14): `artifacts/final_v14`

### Evaluation

- [Gold evaluation labels](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/data/evaluation): `data/evaluation`
- [Classification metrics](https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/evaluation/classification_metrics.py): `src/evaluation/classification_metrics.py`
- [Topic quality metrics](https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/evaluation/topic_quality_metrics.py): `src/evaluation/topic_quality_metrics.py`
- [Evaluation runner](https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/evaluation/run_evaluation.py): `src/evaluation/run_evaluation.py`
- [Extraction audit](https://github.com/himathx/lk-hansard-topic-modeling/blob/main/src/evaluation/extraction_audit.py): `src/evaluation/extraction_audit.py`
- [Evaluation results](https://github.com/himathx/lk-hansard-topic-modeling/tree/main/artifacts/evaluation): `artifacts/evaluation`

### Publication

- **Hugging Face dataset**
- **Interactive dashboard**

### Other components

- **Hansard source**
- **Researchers and reviewers**

## Connections

- Hansard source → Hansard downloader: provides PDFs (evidence: `src/ingestion/hansard_download.py`)
- Hansard Markdown → Speech corpus builder: extracts speeches (evidence: `README.md`)
- Speech corpus builder → Speech-level corpus: builds corpus (evidence: `README.md`)
- Speech-level corpus → Multilingual embeddings: generates embeddings (evidence: `README.md`)
- Multilingual embeddings → Micro-topic discovery: discovers topics (evidence: `README.md`)
- Micro-topic discovery → Macro-topic aggregation: aggregates topics (evidence: `README.md`)
- Macro-topic aggregation → Topic assignments: produces assignments (evidence: `README.md`)
- Gold evaluation labels → Evaluation runner: supplies labels (evidence: `src/evaluation/run_evaluation.py`)
- Topic assignments → Evaluation runner: supplies assignments (evidence: `src/evaluation/run_evaluation.py`)
- Evaluation runner → Classification metrics: calls metrics (evidence: `src/evaluation/run_evaluation.py`)
- Evaluation runner → Topic quality metrics: calls metrics (evidence: `src/evaluation/run_evaluation.py`)
- Evaluation runner → Evaluation results: writes reports (evidence: `src/evaluation/run_evaluation.py`)
- Researchers and reviewers → Extraction audit: audits extraction (evidence: `README.md`)
- Topic assignments → Hugging Face dataset: publishes dataset (evidence: `README.md`)
- Topic assignments → Interactive dashboard: supports dashboard (evidence: `README.md`)
- Hugging Face dataset → Researchers and reviewers: serves dataset (evidence: `README.md`)
- Interactive dashboard → Researchers and reviewers: presents results (evidence: `README.md`)
