Metadata-Version: 2.4
Name: logiglyph
Version: 0.1.1
Summary: Agglutinative language toolkit with logical symbols, translator, and font generator.
Author: Augusto
License-Expression: MIT
Keywords: conlang,translator,font,agglutinative-language
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Operating System :: OS Independent
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: g4f>=0.3.2.7
Requires-Dist: fonttools>=4.56.0
Dynamic: license-file

# Agglutinative Language Toolkit

This project bootstraps a synthetic agglutinative language with:

- A GPT-powered dictionary generator and translator (`g4f` API)
- A logical symbol system where glyph form encodes meaning + sound
- A font generator that compiles symbols into a `.ttf` font

## 1) Setup

```powershell
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt
pip install -e .
```

After editable install, you can use:

- `logiglyph ...` (console command)
- `python -m logiglyph ...`
- `from logiglyph import LanguageModule`

## 2) Generate dictionary

```powershell
python -m src.tool generate-dictionary --count 96 --out data/dictionary.json
```

This calls `g4f` (`gpt-5-mini`) and enriches each root with:

- `semantic_class`
- `onset`, `vowel`, `coda` (sound parts)
- `symbol_id` (logical glyph key)
- `symbol` (ASCII token: `lg_<class>_<root>`)
- `char` (optional Private Use Area glyph)

If API output is malformed/unavailable, the tool falls back to deterministic local roots.

## 3) Build font

```powershell
python -m src.tool build-font --dict data/dictionary.json --out dist/LogiGlyph.ttf
```

This creates:

- `dist/LogiGlyph.ttf`
- `dist/glyph_map.json`

## 4) Translate text

```powershell
python -m src.tool translate --dict data/dictionary.json --text "the person builds a house"
python -m src.tool translate --dict data/dictionary.json --text "lg_e_pa_ lg_e_pan lg_e_pak" --reverse
```

`--reverse` expects ASCII symbols (`lg_<class>_<root>`), not PUA glyph characters.

## 5) Build specimen (visual check)

```powershell
python -m src.tool build-specimen --dict data/dictionary.json --font dist/LogiGlyph.ttf --out dist/specimen.html
```

Open `dist/specimen.html` in a browser. Keep `LogiGlyph.ttf` in the same folder so `@font-face` can load it.

## Font rendering troubleshooting

Default translation output is ASCII (`lg_<class>_<root>`) and renders in any font.
The optional visual glyph mode uses Private Use Area (`U+E100+`) and needs `LogiGlyph.ttf`.

- Terminal/editor showing squares only affects PUA glyphs; ASCII symbols are always safe.
- Browser: use CSS `@font-face` and set `font-family: 'LogiGlyph'` only when rendering PUA glyph text.
- Windows app: install `dist/LogiGlyph.ttf` only if you choose PUA glyph rendering.

Example VS Code setting:

```json
{
  "editor.fontFamily": "LogiGlyph, Consolas, 'Courier New', monospace"
}
```

## Use as a Python module

```python
from logiglyph import LanguageModule

lang = LanguageModule("data/dictionary.json")
res = lang.translate("person_0 house_1 water_2")
print(res.text)        # e.g. lg_e_pa_ lg_e_pan lg_e_pak
print(res.codepoints)  # ['U+E100', 'U+E101', 'U+E102']

print(lang.reverse(res.text))  # person_0 house_1 water_2
print(lang.install_note())
```

## Logical symbol design

Each glyph is compositional and fully rule-driven:

- Semantic radical (base shape):
  - `entity`: box
  - `action`: diagonal cross
  - `quality`: diamond
  - `relation`: bridge bar
  - `abstract`: circle-ish octagon
- Onset class adds a stem direction.
- Vowel places a dot mark in one of 5 anchor positions.
- Coda adds a terminal notch/tick style.

So related meanings and sounds share visible structure.

## Direct g4f usage

The dictionary generator internally uses this same API pattern:

```python
from g4f.client import Client

client = Client()
response = client.chat.completions.create(
    model="gpt-5-mini",
    messages=[{"role": "user", "content": "..." }],
    web_search=False
)
print(response.choices[0].message.content)
```
