# myuon/ai architecture

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

- Interactive diagram: https://gitdiagram.com/myuon/ai
- Repository: https://github.com/myuon/ai

## Overview

This is a Python 2.7 Japanese conversational-learning toy: users chat with an AliceEngine that learns input tokens, persists them, and generates a scored Markov-style reply; alternatively, two engines converse automatically. The README also documents preparing book text or Twitter logs as learning material. The graph preserves the separate experimental chat programs as distinct runtimes. Evidence is limited to the README and excerpted source; the corpus and save directories are represented at directory level where their individual files were not inspected.

Main entry points: [`Alice_AI.py`](https://github.com/myuon/ai/blob/master/Alice_AI.py) (Alice engine), [`text`](https://github.com/myuon/ai/tree/master/text) (Source text corpus), [`save`](https://github.com/myuon/ai/tree/master/save) (Learned token files), [`AI2.py`](https://github.com/myuon/ai/blob/master/AI2.py) (Character n-gram)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Conversation runtimes"]
  node_alice["Alice engine<br/>[Alice_AI.py]"]
  node_dialogue["Two-AI dialogue<br/>[ai2ai.py]"]
end

subgraph group_experiments["Markov experiments"]
  node_ai0["Echo chatbot<br/>[AI0.py]"]
  node_ai2["Character n-gram<br/>[AI2.py]"]
  node_ai3["Morph n-gram<br/>[AI3.py]"]
  node_ai6["Learning Markov<br/>[AI6.py]"]
  node_ai8["Context Markov<br/>[AI8.py]"]
  node_ai10["Scored Markov<br/>[AI10.py]"]
end

subgraph group_preparation["Corpus preparation"]
  node_morph["Text tokenizer<br/>[Cutmorph.py]"]
  node_clean["Log cleaner<br/>[non_number.py]"]
end

subgraph group_data["Learning data"]
  node_text["Source text corpus"]
  node_save[("Learned token files")]
end

node_user(("User"))
node_logs["Twitter CSV log"]

node_user -->|"enters text"| node_alice
node_alice -->|"prints reply"| node_user
node_alice -->|"reads and appends"| node_save
node_dialogue -->|"calls engines"| node_alice
node_user -->|"enters text"| node_ai0
node_user -->|"enters text"| node_ai2
node_user -->|"enters text"| node_ai3
node_user -->|"enters text"| node_ai6
node_user -->|"enters text"| node_ai8
node_user -->|"enters text"| node_ai10
node_ai2 -->|"reads corpus"| node_text
node_ai3 -->|"reads corpus"| node_text
node_ai6 -->|"reads and appends"| node_save
node_ai8 -->|"reads and appends"| node_save
node_ai10 -->|"reads and appends"| node_save
node_text -.->|"provides text"| node_morph
node_morph -->|"writes tokens"| node_save
node_logs -->|"provides CSV"| node_clean
node_clean -->|"writes cleaned text"| node_text
node_text -.->|"seed learning data"| node_alice

click node_alice "https://github.com/myuon/ai/blob/master/Alice_AI.py"
click node_dialogue "https://github.com/myuon/ai/blob/master/ai2ai.py"
click node_ai0 "https://github.com/myuon/ai/blob/master/AI0.py"
click node_ai2 "https://github.com/myuon/ai/blob/master/AI2.py"
click node_ai3 "https://github.com/myuon/ai/blob/master/AI3.py"
click node_ai6 "https://github.com/myuon/ai/blob/master/AI6.py"
click node_ai8 "https://github.com/myuon/ai/blob/master/AI8.py"
click node_ai10 "https://github.com/myuon/ai/blob/master/AI10.py"
click node_morph "https://github.com/myuon/ai/blob/master/Cutmorph.py"
click node_clean "https://github.com/myuon/ai/blob/master/text/non_number.py"
click node_text "https://github.com/myuon/ai/tree/master/text"
click node_save "https://github.com/myuon/ai/tree/master/save"

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_alice,node_dialogue,node_user toneBlue
class node_ai0,node_ai2,node_ai3,node_ai6,node_ai8,node_ai10 toneAmber
class node_morph,node_clean toneMint
class node_text,node_save toneRose
class node_logs toneIndigo
```

## Components

### Conversation runtimes

- [Alice engine](https://github.com/myuon/ai/blob/master/Alice_AI.py): `Alice_AI.py`
- [Two-AI dialogue](https://github.com/myuon/ai/blob/master/ai2ai.py): `ai2ai.py`

### Markov experiments

- [Echo chatbot](https://github.com/myuon/ai/blob/master/AI0.py): `AI0.py`
- [Character n-gram](https://github.com/myuon/ai/blob/master/AI2.py): `AI2.py`
- [Morph n-gram](https://github.com/myuon/ai/blob/master/AI3.py): `AI3.py`
- [Learning Markov](https://github.com/myuon/ai/blob/master/AI6.py): `AI6.py`
- [Context Markov](https://github.com/myuon/ai/blob/master/AI8.py): `AI8.py`
- [Scored Markov](https://github.com/myuon/ai/blob/master/AI10.py): `AI10.py`

### Corpus preparation

- [Text tokenizer](https://github.com/myuon/ai/blob/master/Cutmorph.py): `Cutmorph.py`
- [Log cleaner](https://github.com/myuon/ai/blob/master/text/non_number.py): `text/non_number.py`

### Learning data

- [Source text corpus](https://github.com/myuon/ai/tree/master/text): `text`
- [Learned token files](https://github.com/myuon/ai/tree/master/save): `save`

### Other components

- **User**
- **Twitter CSV log**

## Connections

- User → Alice engine: enters text (evidence: `README.md`)
- Alice engine → User: prints reply (evidence: `Alice_AI.py`)
- Alice engine → Learned token files: reads and appends (evidence: `Alice_AI.py`)
- Two-AI dialogue → Alice engine: calls engines (evidence: `ai2ai.py`)
- User → Echo chatbot: enters text (evidence: `AI0.py`)
- User → Character n-gram: enters text (evidence: `AI2.py`)
- User → Morph n-gram: enters text (evidence: `AI3.py`)
- User → Learning Markov: enters text (evidence: `AI6.py`)
- User → Context Markov: enters text (evidence: `AI8.py`)
- User → Scored Markov: enters text (evidence: `AI10.py`)
- Character n-gram → Source text corpus: reads corpus (evidence: `AI2.py`)
- Morph n-gram → Source text corpus: reads corpus (evidence: `AI3.py`)
- Learning Markov → Learned token files: reads and appends (evidence: `AI6.py`)
- Context Markov → Learned token files: reads and appends (evidence: `AI8.py`)
- Scored Markov → Learned token files: reads and appends (evidence: `AI10.py`)
- Source text corpus → Text tokenizer: provides text (evidence: `README.md`)
- Text tokenizer → Learned token files: writes tokens (evidence: `Cutmorph.py`)
- Twitter CSV log → Log cleaner: provides CSV (evidence: `README.md`)
- Log cleaner → Source text corpus: writes cleaned text (evidence: `text/non_number.py`)
- Source text corpus → Alice engine: seed learning data (evidence: `README.md`)
