# Algorithmic Recursive Sequence Analysis 3.0



This project provides a web-based application for the automatic analysis of dialog transcripts using Sentence-BERT, HDBSCAN clustering, and probabilistic context-free grammars (PCFG).
## Features
* π Upload multiple transcripts
* π§ Sentence-BERT for embeddings
* π HDBSCAN for clustering
* π§Ύ Categorization via GPT or local methods
* π Visualization via UMAP
* π PCFG induction from sequences
* π² Dialog simulation
* π Export PCFG as `.yaml`, `.json`, `.csv`, or `.dot`
## Files
* `app.py` β Main file containing the Streamlit (or tkinter) GUI
* `requirements.txt` β Python dependencies
* `README.md` β This documentation
## Usage
1. Open the web app in your browser
2. Upload `.txt` transcripts
3. The app clusters utterances and generates semantic categories
4. You can export the resulting PCFG or simulate new dialogues
---
# Algorithmic Recursive Sequence Analysis 3.0 (ARS 3.0)
**Algorithmic Recursive Sequence Analysis (ARS 3.0)** is a modular system for the processing, analysis, and simulation of dialogical transcripts. It enables automatic clustering of semantically similar utterances, the generation of probabilistic context-free grammars (PCFG), and the creation of synthetic dialogues based on these structures.
---
## π§ Project Structure
```
ars3/
βββ ars_core.py # Core logic: processing, PCFG export, simulation
βββ app.py # GUI (Streamlit or tkinter)
βββ categories.json # Persistent storage of recognized categories
βββ data/
β βββ test_transcript.txt # Example transcript data for analysis
βββ output/
β βββ pcfg.json # PCFG exported in JSON format
β βββ pcfg.csv # PCFG exported in CSV format
β βββ pcfg.yaml # PCFG exported in YAML format
β βββ cluster_plot.png # Visualization of cluster structure
βββ requirements.txt # Dependencies
βββ setup.py # Installation script
βββ README.md # This file
```
---
## π§ Core Functions
### `ars_core.py`
* **`process_multiple_dialogs(transcript_paths)`**
Loads and processes multiple transcripts, clusters semantically similar statements with HDBSCAN, and builds a PCFG.
* **`simulate_dialog(pcfg, max_turns=10)`**
Simulates a new dialog based on a given PCFG.
* **`export_pcfg_to_json(pcfg, filepath)`**
Exports the PCFG to a JSON file.
* **`export_pcfg_to_csv(pcfg, filepath)`**
Exports the PCFG to a CSV file for tabular analysis.
* **`export_pcfg_to_yaml(pcfg, filepath)`**
Exports the PCFG in YAML format for further processing or editing.
---
## π₯οΈ GUI (`app.py`)
* Select transcripts for processing
* Start analysis and clustering
* Visualize the cluster structure
* Export PCFG in various formats
* Simulate new dialogues at the press of a button
The GUI is modular and can be run via Streamlit (web) or tkinter (local desktop interface).
---
## π¦ Installation
1. Clone or unzip the repository
2. Install the required dependencies:
```bash
pip install -r requirements.txt
```
3. Start the GUI (if `app.py` contains a `main()` function):
```bash
python app.py
```
Or via a command-line shortcut (if installed as CLI):
```bash
ars-gui
```
---
## π Export Formats
* **JSON** β Structured, machine-readable format
* **CSV** β For easy tabular analysis (e.g., in Excel or Pandas)
* **YAML** β For readable configuration and external tool integration
* **DOT** β For graph-based visualization via Graphviz or other tools
---
# Algorithmisch-Rekursive Sequenzanalyse 3.0
Dieses Projekt bietet eine Webanwendung zur automatischen Analyse von dialogischen Transkripten mithilfe von Sentence-BERT, HDBSCAN-Clustering und probabilistischen kontextfreien Grammatiken (PCFG).
## Funktionen
- π Mehrfacher Transkript-Upload
- π§ Sentence-BERT fΓΌr Embedding
- π HDBSCAN fΓΌr Clusterbildung
- π§Ύ Kategorien mit GPT oder lokal
- π Visualisierung via UMAP
- π PCFG-Induktion aus Sequenzen
- π² Simulation von Dialogen
- π Export der PCFG als `.yaml` oder `.dot`
## Dateien
- `app.py` β Die Hauptdatei mit der Streamlit-App
- `requirements.txt` β Python-AbhΓ€ngigkeiten
- `README.md` β Dieses Dokument
## Nutzung
1. Γffne die Web-App im Browser
2. Lade `.txt`-Transkripte hoch
3. Die App clustert ΓuΓerungen und generiert Kategorien
4. Du kannst die resultierende PCFG exportieren oder Dialoge simulieren
# Algorithmisch Rekursive Sequenzanalyse 3.0



**Algorithmisch Rekursive Sequenzanalyse (ARS 3.0)** ist ein modulares System zur Verarbeitung, Analyse und Simulation von dialogischen Transkripten. Es ermΓΆglicht die automatische Clusterung semantisch Γ€hnlicher Aussagen, den Aufbau probabilistischer kontextfreier Grammatiken (PCFG), sowie die Generierung synthetischer Dialoge auf Basis dieser Strukturen.
---
## π§ Projektstruktur
ars3/
βββ ars\_core.py # Zentrale Logik: Verarbeitung, PCFG-Export, Simulation
βββ app.py # GUI (Streamlit oder tkinter)
βββ categories.json # Persistente Speicherung erkannter Kategorien
βββ data/
β βββ test\_transcript.txt # Beispielhafte Dialogdaten zur Analyse
βββ output/
β βββ pcfg.json # Exportierte PCFG im JSON-Format
β βββ pcfg.csv # Exportierte PCFG im CSV-Format
β βββ pcfg.yaml # Exportierte PCFG im YAML-Format
β βββ cluster\_plot.png # Visualisierung der Clusterstruktur
βββ requirements.txt # AbhΓ€ngigkeiten
βββ setup.py # Installationsskript
βββ README.md # Diese Datei
```
---
## π§ Hauptfunktionen
### `ars_core.py`
- **`process_multiple_dialogs(transcript_paths)`**
LΓ€dt mehrere Transkripte, analysiert semantisch Γ€hnliche Aussagen, clustert mit HDBSCAN und erstellt eine PCFG.
- **`simulate_dialog(pcfg, max_turns=10)`**
Simuliert einen plausiblen neuen Dialog basierend auf einer gegebenen PCFG.
- **`export_pcfg_to_json(pcfg, filepath)`**
Exportiert die PCFG in eine JSON-Datei.
- **`export_pcfg_to_csv(pcfg, filepath)`**
Exportiert die PCFG in eine CSV-Datei zur besseren tabellarischen Auswertung.
- **`export_pcfg_to_yaml(pcfg, filepath)`**
Exportiert die PCFG in das YAML-Format (z.β―B. fΓΌr andere Tools oder manuelle Bearbeitung).
---
## π₯οΈ GUI (`app.py`)
- WΓ€hle Transkripte zur Verarbeitung
- Starte Analyse & Clustering
- Visualisiere Clusterstruktur
- Exportiere PCFG in verschiedenen Formaten
- Simuliere neue Dialoge auf Knopfdruck
Die GUI ist modular aufgebaut und kann wahlweise in Streamlit (Web) oder tkinter (lokal) betrieben werden.
## π¦ Installation
1. Klone oder entpacke das Repository:
2. Installiere alle AbhΓ€ngigkeiten:
```bash
pip install -r requirements.txt
```
3. Starte die GUI (wenn `app.py` eine `main()`-Funktion enthΓ€lt):
```bash
python app.py
```
Oder ΓΌber den Konsolenbefehl:
```bash
ars-gui
```
---
## π Exportformate
* **JSON**: FΓΌr strukturierten maschinenlesbaren Export
* **CSV**: Zur einfachen tabellarischen Analyse (z.β―B. in Excel oder Pandas)
* **YAML**: FΓΌr lesbare Konfigurationen und Weiterverarbeitung in externen Tools