# Algorithmic Recursive Sequence Analysis 3.0 ![ARS 3.0 GUI](ARS3.png) ![ARS 4.0 GUI](ARS4.png) ![ARS 6.0 GUI](ARS6.png) 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 ![ARS 3.0 GUI](ARS3.png) ![ARS 4.0 GUI](ARS4.png) ![ARS 6.0 GUI](ARS6.png) **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