# irvallensar/engagement-analyzer-llm architecture

> Architecture diagram of the GitHub repository irvallensar/engagement-analyzer-llm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/irvallensar/engagement-analyzer-llm
- Repository: https://github.com/irvallensar/engagement-analyzer-llm

## Overview

Engagement Analyzer combines a corpus-annotation construction workflow with experiments for token-level engagement extraction. The repository supports sentence preparation, annotation-batch generation, WebAnno formatting, context expansion, post-annotation processing and reliability analysis; its newer experiments add discriminative sequence tagging, synthetic-data workflows, candidate spans and structured LLM extraction. The older construction scripts and newer experiments are not shown as one continuous runtime pipeline. Several research capabilities are documented in the README but their implementations were not sampled, so those links are documented or left unverified.

Main entry points: [`Engagement-Discourse-Treebank-Construction/04_annotation_file_generation/making_annotation_file.py`](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/04_annotation_file_generation/making_annotation_file.py) (Annotation file generation), [`Engagement-Discourse-Treebank-Construction/03_batching/make_corpus_batches.py`](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/03_batching/make_corpus_batches.py) (Corpus batching), [`Engagement-Discourse-Treebank-Construction/05_context_window_extraction/add_contextTosentences.py`](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/05_context_window_extraction/add_contextTosentences.py) (Context expansion), [`Engagement-Discourse-Treebank-Construction/05_context_window_extraction/mutlisentToConll2.py`](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/05_context_window_extraction/mutlisentToConll2.py) (Context TSV export)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_corpus["Corpus preparation"]
  node_tokenize["Sentence tokenization"]
  node_sentenceids["Sentence IDs"]
  node_batching["Corpus batching"]
  node_batchutil["Batch utility<br/>[utils.py]"]
end

subgraph group_annotation["Annotation workflow"]
  node_annotfiles["Annotation file generation"]
  node_context["Context expansion"]
  node_multisent["Context TSV export"]
  node_sampleannot["Construction samples"]
  node_webanno["WebAnno annotation files"]
end

subgraph group_post["Post-annotation"]
  node_integration["Annotated TSV integration"]
  node_postprocess["TSV conversion and folds"]
  node_reliability["Annotation reliability"]
end

subgraph group_models["Extraction research"]
  node_trainingdata["Training data"]
  node_tagging["Discriminative tagging"]
  node_synthetic["Synthetic data workflows"]
  node_candidates["Candidate spans"]
  node_candidateflow["Candidate tuple adapter"]
  node_llm["Structured LLM extraction"]
  node_evaluation["Extraction evaluation<br/>[evaluate_iob.py]"]
end

node_researcher(("Researcher / annotator"))
node_corpora[("Text corpora")]
node_extractionresult["Engagement span results"]

node_corpora -.->|"segments"| node_tokenize
node_tokenize -.->|"identifies"| node_sentenceids
node_sentenceids -.->|"selects for batches"| node_batching
node_batching -->|"uses"| node_batchutil
node_batching -.->|"prepares for annotation"| node_annotfiles
node_annotfiles -->|"batches with"| node_batchutil
node_annotfiles -->|"writes"| node_webanno
node_researcher -.->|"annotates"| node_webanno
node_annotfiles -.->|"provides sentence context"| node_context
node_context -->|"batches with"| node_batchutil
node_context -.->|"exports contextual batches"| node_multisent
node_multisent -->|"imports formatting helpers"| node_sampleannot
node_multisent -->|"writes"| node_webanno
node_webanno -.->|"integrates annotations"| node_integration
node_integration -.->|"converts and partitions"| node_postprocess
node_integration -.->|"supports agreement analysis"| node_reliability
node_postprocess -.->|"formats training data"| node_trainingdata
node_trainingdata -.->|"trains token taggers"| node_tagging
node_trainingdata -.->|"augments data"| node_synthetic
node_researcher -.->|"submits text"| node_candidates
node_candidates -->|"supplies candidates"| node_candidateflow
node_candidateflow -->|"returns span tuples"| node_extractionresult
node_researcher -.->|"provides prompt"| node_llm
node_llm -->|"generates structured spans"| node_extractionresult
node_tagging -.->|"evaluates predictions"| node_evaluation
node_llm -.->|"benchmarks extraction"| node_evaluation
node_evaluation -.->|"scores spans"| node_extractionresult

click node_tokenize "https://github.com/irvallensar/engagement-analyzer-llm/tree/main/Engagement-Discourse-Treebank-Construction/01_sentence_tokenization"
click node_sentenceids "https://github.com/irvallensar/engagement-analyzer-llm/tree/main/Engagement-Discourse-Treebank-Construction/02_sentence_id_extraction"
click node_batching "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/03_batching/make_corpus_batches.py"
click node_batchutil "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/scr/utils.py"
click node_annotfiles "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/04_annotation_file_generation/making_annotation_file.py"
click node_context "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/05_context_window_extraction/add_contextTosentences.py"
click node_multisent "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/05_context_window_extraction/mutlisentToConll2.py"
click node_sampleannot "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/construction_specific_samples/scripts/making_annotation_file3.py"
click node_integration "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/06_post_annotation/tsv_related/integrate_annotated.py"
click node_postprocess "https://github.com/irvallensar/engagement-analyzer-llm/tree/main/Engagement-Discourse-Treebank-Construction/06_post_annotation/post_process"
click node_reliability "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/06_post_annotation/reliability/accuracy_calculator.py"
click node_trainingdata "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/convert_iob_to_jsonl.py"
click node_tagging "https://github.com/irvallensar/engagement-analyzer-llm/tree/main/scripts"
click node_synthetic "https://github.com/irvallensar/engagement-analyzer-llm/tree/main/scripts"
click node_candidates "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/suggester/custom_suggester.py"
click node_candidateflow "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/scripts/candidate_llm_pipeline.py"
click node_llm "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/scripts/local_llm_client_4.py"
click node_evaluation "https://github.com/irvallensar/engagement-analyzer-llm/blob/main/scripts/evaluate_iob.py"

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_tokenize,node_sentenceids,node_batching,node_batchutil toneBlue
class node_annotfiles,node_context,node_multisent,node_sampleannot,node_webanno,node_corpora toneAmber
class node_integration,node_postprocess,node_reliability toneMint
class node_trainingdata,node_tagging,node_synthetic,node_candidates,node_candidateflow,node_llm,node_evaluation toneRose
class node_researcher,node_extractionresult toneIndigo
```

## Components

### Corpus preparation

- [Sentence tokenization](https://github.com/irvallensar/engagement-analyzer-llm/tree/main/Engagement-Discourse-Treebank-Construction/01_sentence_tokenization): `Engagement-Discourse-Treebank-Construction/01_sentence_tokenization`
- [Sentence IDs](https://github.com/irvallensar/engagement-analyzer-llm/tree/main/Engagement-Discourse-Treebank-Construction/02_sentence_id_extraction): `Engagement-Discourse-Treebank-Construction/02_sentence_id_extraction`
- [Corpus batching](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/03_batching/make_corpus_batches.py): `Engagement-Discourse-Treebank-Construction/03_batching/make_corpus_batches.py`
- [Batch utility](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/scr/utils.py): `Engagement-Discourse-Treebank-Construction/scr/utils.py`

### Annotation workflow

- [Annotation file generation](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/04_annotation_file_generation/making_annotation_file.py): `Engagement-Discourse-Treebank-Construction/04_annotation_file_generation/making_annotation_file.py`
- [Context expansion](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/05_context_window_extraction/add_contextTosentences.py): `Engagement-Discourse-Treebank-Construction/05_context_window_extraction/add_contextTosentences.py`
- [Context TSV export](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/05_context_window_extraction/mutlisentToConll2.py): `Engagement-Discourse-Treebank-Construction/05_context_window_extraction/mutlisentToConll2.py`
- [Construction samples](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/construction_specific_samples/scripts/making_annotation_file3.py): `Engagement-Discourse-Treebank-Construction/construction_specific_samples/scripts/making_annotation_file3.py`
- **WebAnno annotation files**

### Post-annotation

- [Annotated TSV integration](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/06_post_annotation/tsv_related/integrate_annotated.py): `Engagement-Discourse-Treebank-Construction/06_post_annotation/tsv_related/integrate_annotated.py`
- [TSV conversion and folds](https://github.com/irvallensar/engagement-analyzer-llm/tree/main/Engagement-Discourse-Treebank-Construction/06_post_annotation/post_process): `Engagement-Discourse-Treebank-Construction/06_post_annotation/post_process`
- [Annotation reliability](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/Engagement-Discourse-Treebank-Construction/06_post_annotation/reliability/accuracy_calculator.py): `Engagement-Discourse-Treebank-Construction/06_post_annotation/reliability/accuracy_calculator.py`

### Extraction research

- [Training data](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/convert_iob_to_jsonl.py): `convert_iob_to_jsonl.py`
- [Discriminative tagging](https://github.com/irvallensar/engagement-analyzer-llm/tree/main/scripts): `scripts`
- [Synthetic data workflows](https://github.com/irvallensar/engagement-analyzer-llm/tree/main/scripts): `scripts`
- [Candidate spans](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/suggester/custom_suggester.py): `suggester/custom_suggester.py`
- [Candidate tuple adapter](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/scripts/candidate_llm_pipeline.py): `scripts/candidate_llm_pipeline.py`
- [Structured LLM extraction](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/scripts/local_llm_client_4.py): `scripts/local_llm_client_4.py`
- [Extraction evaluation](https://github.com/irvallensar/engagement-analyzer-llm/blob/main/scripts/evaluate_iob.py): `scripts/evaluate_iob.py`

### Other components

- **Researcher / annotator**
- **Text corpora**
- **Engagement span results**

## Connections

- Text corpora → Sentence tokenization: segments (evidence: `README.md`)
- Sentence tokenization → Sentence IDs: identifies (evidence: `README.md`)
- Sentence IDs → Corpus batching: selects for batches (evidence: `README.md`)
- Corpus batching → Batch utility: uses (evidence: `Engagement-Discourse-Treebank-Construction/03_batching/make_corpus_batches.py`)
- Corpus batching → Annotation file generation: prepares for annotation (evidence: `README.md`)
- Annotation file generation → Batch utility: batches with (evidence: `Engagement-Discourse-Treebank-Construction/04_annotation_file_generation/making_annotation_file.py`)
- Annotation file generation → WebAnno annotation files: writes (evidence: `Engagement-Discourse-Treebank-Construction/04_annotation_file_generation/making_annotation_file.py`)
- Researcher / annotator → WebAnno annotation files: annotates (evidence: `README.md`)
- Annotation file generation → Context expansion: provides sentence context (evidence: `README.md`)
- Context expansion → Batch utility: batches with (evidence: `Engagement-Discourse-Treebank-Construction/05_context_window_extraction/add_contextTosentences.py`)
- Context expansion → Context TSV export: exports contextual batches (evidence: `README.md`)
- Context TSV export → Construction samples: imports formatting helpers (evidence: `Engagement-Discourse-Treebank-Construction/05_context_window_extraction/mutlisentToConll2.py`)
- Context TSV export → WebAnno annotation files: writes (evidence: `Engagement-Discourse-Treebank-Construction/05_context_window_extraction/mutlisentToConll2.py`)
- WebAnno annotation files → Annotated TSV integration: integrates annotations (evidence: `README.md`)
- Annotated TSV integration → TSV conversion and folds: converts and partitions (evidence: `README.md`)
- Annotated TSV integration → Annotation reliability: supports agreement analysis (evidence: `README.md`)
- TSV conversion and folds → Training data: formats training data (evidence: `README.md`)
- Training data → Discriminative tagging: trains token taggers (evidence: `README.md`)
- Training data → Synthetic data workflows: augments data (evidence: `README.md`)
- Researcher / annotator → Candidate spans: submits text
- Candidate spans → Candidate tuple adapter: supplies candidates (evidence: `scripts/candidate_llm_pipeline.py`)
- Candidate tuple adapter → Engagement span results: returns span tuples (evidence: `scripts/candidate_llm_pipeline.py`)
- Researcher / annotator → Structured LLM extraction: provides prompt
- Structured LLM extraction → Engagement span results: generates structured spans (evidence: `scripts/local_llm_client_4.py`)
- Discriminative tagging → Extraction evaluation: evaluates predictions (evidence: `README.md`)
- Structured LLM extraction → Extraction evaluation: benchmarks extraction (evidence: `README.md`)
- Extraction evaluation → Engagement span results: scores spans (evidence: `README.md`)
