Rule-based Coptic-to-Latin transliteration with Greco-Bohairic phonetic rules โ pure Python, no dependencies
Project description
๐ค Coptic Transliteration Tool with AI Enhancement
A modern web-based tool for transliterating Coptic text to Latin script, enhanced with Google's Gemini 2.5 Flash Lite AI model. Live Application: (https://ai-coptic-transliterator.streamlit.app/)
โจ Features
- ๐๏ธ Flexible Input: Enter Coptic text directly, upload
.txtfiles, or build text with the on-screen Coptic character palette (no Coptic keyboard needed). - โจ AI-Enhanced: Combines rule-based transliteration with Google's Gemini 2.5 Flash Lite model for superior accuracy and context-aware results.
- ๐ Interlinear View: Each Latin word rendered directly under its Coptic word โ ideal for following along in church services.
- ๐ Text Library: Common liturgical texts (Lord's Prayer, Trisagion, Kyrie eleison, โฆ) one click away, community-maintained in
texts/library.json. - ๐ฃ๏ธ Pronunciation Guide: Built-in letter-by-letter Greco-Bohairic pronunciation reference with IPA.
- ๐ Side-by-Side Comparison: View both rule-based and AI-enhanced results simultaneously.
- โฌ๏ธ Export Ready: Download results as
.txt, or export the interlinear view as a printable page for service bulletins. - ๐ Fast & Reliable: The rule-based engine handles everything on its own when no API key is configured or the API is unreachable โ the tool never goes down.
๐ Quick Start
Prerequisites
- Python 3.9+
- Google Gemini API key (for AI enhancement - optional)
Local Setup
-
Clone the Repository
git clone https://github.com/shehata-consulting/coptic-transliterator-llm.git cd coptic-transliterator-llm
-
Create Virtual Environment
python -m venv coptic-llm source coptic-llm/bin/activate # On Windows: coptic-llm\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Configure API Access (Optional)
-
Get your Google AI Studio API key
-
Create
.envfile:GEMINI_API_KEY=your-google-ai-api-key-here
-
Note: The tool works without an API key using rule-based transliteration only
-
-
Launch the App
streamlit run app.py
Your app will be available at
http://localhost:8501
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Streamlit โ โ Rule-based โ โ Google Gemini โ
โ Frontend โโโโโถโ Transliterator โโโโโถโ 2.5 Flash Lite โ
โ โ โ (Always Works) โ โ (Enhancement) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
- Frontend: Streamlit provides the web interface with side-by-side comparison
- Core Logic: Rule-based transliteration ensures reliability
- Enhancement: Gemini 2.5 Flash Lite model via Google AI Studio API
๐ Project Structure
coptic-transliterator-llm/
โโโ app.py # Main Streamlit application (UI only)
โโโ coptictranslit/ # Rule-based engine, on PyPI as `coptic-transliterator`
โโโ text_utils.py # Pure helpers: chunking, LLM output cleaning, interlinear pairing
โโโ texts/library.json # Community-maintained liturgical text library
โโโ tests/ # Pytest suite (run: python -m pytest)
โโโ .streamlit/config.toml # Theme (committed; secrets.toml is not)
โโโ .github/workflows/ # ci.yml (lint+tests) and publish.yml (PyPI on tag)
โโโ pyproject.toml # Package metadata for the PyPI release
โโโ requirements.txt # App dependencies
โโโ requirements-dev.txt # pytest + ruff
โโโ .env.example # Environment variables template
โโโ LICENSE # MIT License
โโโ README.md # This file
โ๏ธ Configuration
Environment Variables
| Variable | Description | Required | Default |
|---|---|---|---|
GEMINI_API_KEY |
Google AI Studio API key for AI enhancement | No | Rule-based only |
SDK Configuration
The tool uses the official google-genai SDK for API communication, replacing raw HTTP requests. The client is initialized in app.py:
from google import genai
client = genai.Client(api_key=GEMINI_API_KEY)
response = client.models.generate_content(
model="gemini-2.5-flash-lite",
contents=prompt,
config=...
)
๐ง Advanced Usage
Use It in Your Own Projects (PyPI)
The rule-based engine ships as the coptic-transliterator package โ pure Python, zero dependencies (the import name is the shorter coptictranslit):
pip install coptic-transliterator
from coptictranslit import translit, translit_with_warnings
print(translit("โฒกโฒโฒโฒฉโฒงโฒ")) # pnoute
print(translit("โฒโฒฉโฒโฒ
โฒ
โฒโฒโฒโฒโฒ")) # evangelion
result, unmapped = translit_with_warnings("โฒกโฒโฒโฒฉโฒงโฒ")
It also installs a CLI for batch work:
coptictranslit hymn.txt -o hymn_latin.txt
echo "โฒโฒ
โฒโฒกโฒ" | coptictranslit
Customization
- Character Mappings: Modify
char_mapincoptictranslit/__init__.py - Contextual Rules: Update
_apply_contextual_rules()method - UI Styling: Customize CSS in
app.py - System Instructions: Modify the system_instruction prompt in app.py to adjust how the LLM formats the output.
๐ Performance & Limitations
AI Enhancement Notes
- Google AI Studio: Uses generous free tier with rate limits
- Fallback: Rule-based method always available when AI is unavailable
- Accuracy: AI enhancement improves context-aware transliteration
- Performance: Rule-based is instant, AI enhancement takes 2-5 seconds
Accuracy Comparison
- Rule-based transliteration provides consistent, fast results
- AI enhancement improves context-aware transliteration for complex texts
- Side-by-side comparison lets users choose the best result
- Performance varies with input complexity and model availability
๐ Examples
Quick Examples
| Coptic | Rule-based | AI-Enhanced | Meaning |
|---|---|---|---|
| โฒกโฒโฒโฒฉโฒงโฒ | pnoute | pnoute | God |
| โฒงโฒโฒโฒโฒโฒโฒฅโฒโฒ | tekklesia | tekklesia | Church |
| โฒโฒ โฒโฒกโฒ | aghape | agape | Love |
| โฒโฒโฒฃโฒโฒ | maria | maria | Mary |
Usage in Code
from transliterator import CopticTransliterator
# Create transliterator instance
ct = CopticTransliterator()
# Transliterate text
result = ct.translit("โฒโฒโฒโฒ โฒโฒฉโฒ โฒโฒฉโฒโฒโฒโฒโฒโฒฉโฒงโฒ")
print(result) # Output: anok oun oumaiฬnoute
๐ค Contributing
Getting Started
-
Fork the Repository
-
Create a Feature Branch
git checkout -b feature/your-feature-name
-
Make Your Changes
-
Test Thoroughly
streamlit run app.py
-
Submit a Pull Request
Development Guidelines
- Follow PEP 8 for Python code style
- Test both with and without API keys
- Update documentation as needed
- Ensure mobile responsiveness
Ideas for Contributions
- Additional contextual transliteration rules
- Support for other Coptic dialects
- Batch processing for large texts
- Performance optimizations
- Enhanced error handling
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฌ Support & Contact
- Issues: GitHub Issues
- Email: shehatam.dev@gmail.com
- Pull Requests: Contributions welcome!
๐ Acknowledgments
- Based on the original coptic-transliterator
- Powered by Google AI Studio
- Built with Streamlit
- Special thanks to the Coptic community for feedback and support
Made with โค๏ธ for the Coptic community
Preserving ancient language through modern technology
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coptic_transliterator-2.0.0.tar.gz.
File metadata
- Download URL: coptic_transliterator-2.0.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bfe3a5cf19059ba3d0fd28749211203f29a3a0fe011fa759de8063614da276c
|
|
| MD5 |
194435cb0b449a605484b71904354b6a
|
|
| BLAKE2b-256 |
4f90fdc50a053292d9f7a321f9d9c6114cce133b9d96dd0287d54188ec998f9c
|
Provenance
The following attestation bundles were made for coptic_transliterator-2.0.0.tar.gz:
Publisher:
publish.yml on shehata-consulting/coptic-transliterator-llm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coptic_transliterator-2.0.0.tar.gz -
Subject digest:
9bfe3a5cf19059ba3d0fd28749211203f29a3a0fe011fa759de8063614da276c - Sigstore transparency entry: 2168692604
- Sigstore integration time:
-
Permalink:
shehata-consulting/coptic-transliterator-llm@04a278725e080b30db8b2b424816e339712ec239 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/shehata-consulting
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04a278725e080b30db8b2b424816e339712ec239 -
Trigger Event:
push
-
Statement type:
File details
Details for the file coptic_transliterator-2.0.0-py3-none-any.whl.
File metadata
- Download URL: coptic_transliterator-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c3292c843add38b5acbfc21fe5124184fde1cc93d1cc91888fb97f321f991b8
|
|
| MD5 |
b2a71d2b59f227ef256f142d29bf725e
|
|
| BLAKE2b-256 |
9001001f6494721131ea0d3fd7d7bbd92f7a0b7811ae572711b8b85d57a6260a
|
Provenance
The following attestation bundles were made for coptic_transliterator-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on shehata-consulting/coptic-transliterator-llm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coptic_transliterator-2.0.0-py3-none-any.whl -
Subject digest:
7c3292c843add38b5acbfc21fe5124184fde1cc93d1cc91888fb97f321f991b8 - Sigstore transparency entry: 2168692706
- Sigstore integration time:
-
Permalink:
shehata-consulting/coptic-transliterator-llm@04a278725e080b30db8b2b424816e339712ec239 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/shehata-consulting
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04a278725e080b30db8b2b424816e339712ec239 -
Trigger Event:
push
-
Statement type: