Skip to main content

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/)

CI License: MIT Python 3.9+


โœจ Features

  • ๐Ÿ–Š๏ธ Flexible Input: Enter Coptic text directly, upload .txt files, 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

  1. Clone the Repository

    git clone https://github.com/shehata-consulting/coptic-transliterator-llm.git
    cd coptic-transliterator-llm
    
  2. Create Virtual Environment

    python -m venv coptic-llm
    source coptic-llm/bin/activate  # On Windows: coptic-llm\Scripts\activate
    
  3. Install Dependencies

    pip install -r requirements.txt
    
  4. Configure API Access (Optional)

    • Get your Google AI Studio API key

    • Create .env file:

      GEMINI_API_KEY=your-google-ai-api-key-here
      
    • Note: The tool works without an API key using rule-based transliteration only

  5. 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_map in coptictranslit/__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

  1. Fork the Repository

  2. Create a Feature Branch

    git checkout -b feature/your-feature-name
    
  3. Make Your Changes

  4. Test Thoroughly

    streamlit run app.py
    
  5. 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


๐Ÿ™ Acknowledgments


Made with โค๏ธ for the Coptic community
Preserving ancient language through modern technology

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coptic_transliterator-2.0.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coptic_transliterator-2.0.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

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

Hashes for coptic_transliterator-2.0.0.tar.gz
Algorithm Hash digest
SHA256 9bfe3a5cf19059ba3d0fd28749211203f29a3a0fe011fa759de8063614da276c
MD5 194435cb0b449a605484b71904354b6a
BLAKE2b-256 4f90fdc50a053292d9f7a321f9d9c6114cce133b9d96dd0287d54188ec998f9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for coptic_transliterator-2.0.0.tar.gz:

Publisher: publish.yml on shehata-consulting/coptic-transliterator-llm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file coptic_transliterator-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for coptic_transliterator-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c3292c843add38b5acbfc21fe5124184fde1cc93d1cc91888fb97f321f991b8
MD5 b2a71d2b59f227ef256f142d29bf725e
BLAKE2b-256 9001001f6494721131ea0d3fd7d7bbd92f7a0b7811ae572711b8b85d57a6260a

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page