toto-lang 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,237 @@
1
+ Metadata-Version: 2.4
2
+ Name: toto-lang
3
+ Version: 0.1.0
4
+ Summary: English-to-Toto translation engine with LLM-powered morphological analysis and Unicode 14.0 script support.
5
+ Author: Toto Documentation Initiative
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/toto-lang/toto-python
8
+ Keywords: toto,translation,nlp,endangered-language,sino-tibetan,unicode
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Text Processing :: Linguistic
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: openai>=1.0
23
+ Requires-Dist: flask>=3.0
24
+
25
+ # toto
26
+
27
+ A Python library for the Toto language — a critically endangered Sino-Tibetan language spoken in Totopara, Alipurduar, West Bengal, India.
28
+
29
+ Provides LLM-powered English-to-Toto translation with morphemic analysis, Unicode 14.0 script transliteration, an offline dictionary of ~7,000 verified entries, and a local web interface.
30
+
31
+ ---
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install -e .
37
+ ```
38
+
39
+ Or install dependencies separately:
40
+
41
+ ```bash
42
+ pip install openai>=1.0 flask>=3.0
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Setup
48
+
49
+ The library needs an API key for the translation model. By default it uses [Ollama Cloud](https://ollama.com) with the `nemotron-3-super:cloud` model.
50
+
51
+ ### 1. Create a `.env` file
52
+
53
+ Create a `.env` file **in your project root** (the directory where your script runs):
54
+
55
+ ```
56
+ TOTO_API_KEY=your-api-key-here
57
+ ```
58
+
59
+ The library also recognises these variable names (checked in order):
60
+
61
+ | Variable | Source |
62
+ |---|---|
63
+ | `TOTO_API_KEY` | Recommended |
64
+ | `TOTO_API` | Alternative |
65
+ | `OLLAMA_API_KEY` | Ollama Cloud |
66
+ | `HF_TOKEN` | HuggingFace |
67
+
68
+ ### 2. Or configure programmatically
69
+
70
+ ```python
71
+ import toto
72
+
73
+ toto.configure(api_key="your-key-here")
74
+ # Or load from a specific .env file:
75
+ toto.configure(env_path="/path/to/your/.env")
76
+ # Or override the endpoint entirely:
77
+ toto.configure(
78
+ api_key="your-key",
79
+ base_url="https://your-endpoint/v1",
80
+ model="your-model-name"
81
+ )
82
+ ```
83
+
84
+ ### Optional: Custom endpoint
85
+
86
+ Set these in your `.env` to override defaults:
87
+
88
+ ```
89
+ TOTO_BASE_URL=https://your-endpoint/v1
90
+ TOTO_MODEL=your-model-name
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Usage
96
+
97
+ ### Translate
98
+
99
+ ```python
100
+ from toto import totoagent
101
+
102
+ result = totoagent.translate("They should not stay outside", lang="en")
103
+
104
+ print(result) # Romanized Toto (str)
105
+ print(result.script) # Native Toto script (Unicode 14.0)
106
+ print(result.roman) # Same as str(result)
107
+ print(result.gloss) # Interlinear morpheme breakdown
108
+ print(result.notes) # Grammatical synthesis explanation
109
+ print(result.reasoning) # Full chain-of-thought reasoning trace
110
+ ```
111
+
112
+ ### Serialise results
113
+
114
+ ```python
115
+ result.to_dict() # -> dict
116
+ result.to_json() # -> JSON string
117
+ ```
118
+
119
+ ### Unicode transliteration (no API key needed)
120
+
121
+ ```python
122
+ from toto import roman_to_toto, toto_to_roman
123
+
124
+ script = roman_to_toto("ka ti da-ro")
125
+ print(script) # 𞊔𞊭 𞊒𞊡 𞊓𞊭-𞊟𞊪
126
+
127
+ roman = toto_to_roman(script)
128
+ print(roman) # ka ti da-ro
129
+ ```
130
+
131
+ ### Offline dictionary lookup (no API key needed)
132
+
133
+ ```python
134
+ from toto import get_lexicon
135
+
136
+ lex = get_lexicon()
137
+ results = lex.lookup("water")
138
+ for entry in results:
139
+ print(f"{entry['english']} -> {entry['toto']}")
140
+ ```
141
+
142
+ ### Web interface
143
+
144
+ ```python
145
+ from toto import webagent
146
+
147
+ webagent.run(port=5001)
148
+ # Open http://127.0.0.1:5001 in your browser
149
+ ```
150
+
151
+ ### Access bundled documentation
152
+
153
+ ```python
154
+ import toto
155
+
156
+ docs = toto.get_documents()
157
+ for path in docs:
158
+ print(path)
159
+ # -> .../Guha_et_al_2025_Morphological_Analysis_Toto.pdf
160
+ # -> .../Toby_Anderson_2017_Toto_English_Dictionary.pdf
161
+ ```
162
+
163
+ ### Create a dedicated agent instance
164
+
165
+ ```python
166
+ from toto import TotoAgent
167
+
168
+ agent = TotoAgent(
169
+ api_key="your-key",
170
+ base_url="https://ollama.com/v1",
171
+ model="nemotron-3-super:cloud"
172
+ )
173
+ result = agent.translate("Good morning")
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Error Handling
179
+
180
+ The library raises descriptive exceptions with actionable guidance:
181
+
182
+ ```python
183
+ from toto import totoagent, MissingApiKeyError, ModelConnectionError, TranslationError
184
+
185
+ try:
186
+ result = totoagent.translate("Hello")
187
+ except MissingApiKeyError:
188
+ print("No API key found — check your .env file")
189
+ except ModelConnectionError:
190
+ print("Cannot reach the translation API")
191
+ except TranslationError as e:
192
+ print(f"Translation failed: {e}")
193
+ print(f"Raw content: {e.raw_content}")
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Project Structure
199
+
200
+ ```
201
+ toto-python/
202
+ ├── pyproject.toml
203
+ ├── setup.py
204
+ ├── README.md
205
+ ├── requirements.txt
206
+ ├── toto/
207
+ │ ├── __init__.py # Public API
208
+ │ ├── config.py # .env auto-discovery
209
+ │ ├── exceptions.py # Exception classes
210
+ │ ├── agent.py # TotoAgent + TranslationResult
211
+ │ ├── unicode.py # Script transliteration
212
+ │ ├── lexicon.py # Offline dictionary
213
+ │ ├── web.py # Web interface
214
+ │ ├── resources/
215
+ │ │ ├── data/ # Bundled JSONL lexicon
216
+ │ │ ├── grammar/ # Grammar specification
217
+ │ │ └── docs/ # Research PDFs
218
+ │ ├── templates/ # HTML templates
219
+ │ └── static/ # CSS & JS
220
+ └── tests/
221
+ └── test_library.py
222
+ ```
223
+
224
+ ---
225
+
226
+ ## References
227
+
228
+ - Toby Anderson, *Toto–English Dictionary*, Totopara Community, 2017.
229
+ - Guha et al., *Morphological Analysis of Toto*, Adamas University, 2025.
230
+ - Unicode 14.0 Toto Block (U+1E290 – U+1E2BF), September 2021.
231
+ - Script created by Padma Shri Dhaniram Toto, 2015.
232
+
233
+ ---
234
+
235
+ ## License
236
+
237
+ MIT
@@ -0,0 +1,213 @@
1
+ # toto
2
+
3
+ A Python library for the Toto language — a critically endangered Sino-Tibetan language spoken in Totopara, Alipurduar, West Bengal, India.
4
+
5
+ Provides LLM-powered English-to-Toto translation with morphemic analysis, Unicode 14.0 script transliteration, an offline dictionary of ~7,000 verified entries, and a local web interface.
6
+
7
+ ---
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install -e .
13
+ ```
14
+
15
+ Or install dependencies separately:
16
+
17
+ ```bash
18
+ pip install openai>=1.0 flask>=3.0
19
+ ```
20
+
21
+ ---
22
+
23
+ ## Setup
24
+
25
+ The library needs an API key for the translation model. By default it uses [Ollama Cloud](https://ollama.com) with the `nemotron-3-super:cloud` model.
26
+
27
+ ### 1. Create a `.env` file
28
+
29
+ Create a `.env` file **in your project root** (the directory where your script runs):
30
+
31
+ ```
32
+ TOTO_API_KEY=your-api-key-here
33
+ ```
34
+
35
+ The library also recognises these variable names (checked in order):
36
+
37
+ | Variable | Source |
38
+ |---|---|
39
+ | `TOTO_API_KEY` | Recommended |
40
+ | `TOTO_API` | Alternative |
41
+ | `OLLAMA_API_KEY` | Ollama Cloud |
42
+ | `HF_TOKEN` | HuggingFace |
43
+
44
+ ### 2. Or configure programmatically
45
+
46
+ ```python
47
+ import toto
48
+
49
+ toto.configure(api_key="your-key-here")
50
+ # Or load from a specific .env file:
51
+ toto.configure(env_path="/path/to/your/.env")
52
+ # Or override the endpoint entirely:
53
+ toto.configure(
54
+ api_key="your-key",
55
+ base_url="https://your-endpoint/v1",
56
+ model="your-model-name"
57
+ )
58
+ ```
59
+
60
+ ### Optional: Custom endpoint
61
+
62
+ Set these in your `.env` to override defaults:
63
+
64
+ ```
65
+ TOTO_BASE_URL=https://your-endpoint/v1
66
+ TOTO_MODEL=your-model-name
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Usage
72
+
73
+ ### Translate
74
+
75
+ ```python
76
+ from toto import totoagent
77
+
78
+ result = totoagent.translate("They should not stay outside", lang="en")
79
+
80
+ print(result) # Romanized Toto (str)
81
+ print(result.script) # Native Toto script (Unicode 14.0)
82
+ print(result.roman) # Same as str(result)
83
+ print(result.gloss) # Interlinear morpheme breakdown
84
+ print(result.notes) # Grammatical synthesis explanation
85
+ print(result.reasoning) # Full chain-of-thought reasoning trace
86
+ ```
87
+
88
+ ### Serialise results
89
+
90
+ ```python
91
+ result.to_dict() # -> dict
92
+ result.to_json() # -> JSON string
93
+ ```
94
+
95
+ ### Unicode transliteration (no API key needed)
96
+
97
+ ```python
98
+ from toto import roman_to_toto, toto_to_roman
99
+
100
+ script = roman_to_toto("ka ti da-ro")
101
+ print(script) # 𞊔𞊭 𞊒𞊡 𞊓𞊭-𞊟𞊪
102
+
103
+ roman = toto_to_roman(script)
104
+ print(roman) # ka ti da-ro
105
+ ```
106
+
107
+ ### Offline dictionary lookup (no API key needed)
108
+
109
+ ```python
110
+ from toto import get_lexicon
111
+
112
+ lex = get_lexicon()
113
+ results = lex.lookup("water")
114
+ for entry in results:
115
+ print(f"{entry['english']} -> {entry['toto']}")
116
+ ```
117
+
118
+ ### Web interface
119
+
120
+ ```python
121
+ from toto import webagent
122
+
123
+ webagent.run(port=5001)
124
+ # Open http://127.0.0.1:5001 in your browser
125
+ ```
126
+
127
+ ### Access bundled documentation
128
+
129
+ ```python
130
+ import toto
131
+
132
+ docs = toto.get_documents()
133
+ for path in docs:
134
+ print(path)
135
+ # -> .../Guha_et_al_2025_Morphological_Analysis_Toto.pdf
136
+ # -> .../Toby_Anderson_2017_Toto_English_Dictionary.pdf
137
+ ```
138
+
139
+ ### Create a dedicated agent instance
140
+
141
+ ```python
142
+ from toto import TotoAgent
143
+
144
+ agent = TotoAgent(
145
+ api_key="your-key",
146
+ base_url="https://ollama.com/v1",
147
+ model="nemotron-3-super:cloud"
148
+ )
149
+ result = agent.translate("Good morning")
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Error Handling
155
+
156
+ The library raises descriptive exceptions with actionable guidance:
157
+
158
+ ```python
159
+ from toto import totoagent, MissingApiKeyError, ModelConnectionError, TranslationError
160
+
161
+ try:
162
+ result = totoagent.translate("Hello")
163
+ except MissingApiKeyError:
164
+ print("No API key found — check your .env file")
165
+ except ModelConnectionError:
166
+ print("Cannot reach the translation API")
167
+ except TranslationError as e:
168
+ print(f"Translation failed: {e}")
169
+ print(f"Raw content: {e.raw_content}")
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Project Structure
175
+
176
+ ```
177
+ toto-python/
178
+ ├── pyproject.toml
179
+ ├── setup.py
180
+ ├── README.md
181
+ ├── requirements.txt
182
+ ├── toto/
183
+ │ ├── __init__.py # Public API
184
+ │ ├── config.py # .env auto-discovery
185
+ │ ├── exceptions.py # Exception classes
186
+ │ ├── agent.py # TotoAgent + TranslationResult
187
+ │ ├── unicode.py # Script transliteration
188
+ │ ├── lexicon.py # Offline dictionary
189
+ │ ├── web.py # Web interface
190
+ │ ├── resources/
191
+ │ │ ├── data/ # Bundled JSONL lexicon
192
+ │ │ ├── grammar/ # Grammar specification
193
+ │ │ └── docs/ # Research PDFs
194
+ │ ├── templates/ # HTML templates
195
+ │ └── static/ # CSS & JS
196
+ └── tests/
197
+ └── test_library.py
198
+ ```
199
+
200
+ ---
201
+
202
+ ## References
203
+
204
+ - Toby Anderson, *Toto–English Dictionary*, Totopara Community, 2017.
205
+ - Guha et al., *Morphological Analysis of Toto*, Adamas University, 2025.
206
+ - Unicode 14.0 Toto Block (U+1E290 – U+1E2BF), September 2021.
207
+ - Script created by Padma Shri Dhaniram Toto, 2015.
208
+
209
+ ---
210
+
211
+ ## License
212
+
213
+ MIT
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "toto-lang"
7
+ version = "0.1.0"
8
+ description = "English-to-Toto translation engine with LLM-powered morphological analysis and Unicode 14.0 script support."
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ {name = "Toto Documentation Initiative"},
14
+ ]
15
+ keywords = ["toto", "translation", "nlp", "endangered-language", "sino-tibetan", "unicode"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Intended Audience :: Science/Research",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
27
+ "Topic :: Text Processing :: Linguistic",
28
+ ]
29
+ dependencies = [
30
+ "openai>=1.0",
31
+ "flask>=3.0",
32
+ ]
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/toto-lang/toto-python"
36
+
37
+ [tool.setuptools.packages.find]
38
+ include = ["toto*"]
39
+
40
+ [tool.setuptools.package-data]
41
+ toto = [
42
+ "resources/data/*.jsonl",
43
+ "resources/grammar/*.md",
44
+ "resources/docs/*.pdf",
45
+ "templates/*.html",
46
+ "static/css/*.css",
47
+ "static/js/*.js",
48
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ """Backwards-compatible setup script. See pyproject.toml for metadata."""
2
+ from setuptools import setup
3
+
4
+ if __name__ == "__main__":
5
+ setup()