Metadata-Version: 2.5
Name: sinhala2roman
Version: 0.1.0
Summary: Lightweight, fast, and deterministic Sinhala to Romanized (Singlish) transliteration library.
Project-URL: Homepage, https://github.com/sehan-dissanayake/sinhala2roman
Project-URL: Repository, https://github.com/sehan-dissanayake/sinhala2roman
Project-URL: Issues, https://github.com/sehan-dissanayake/sinhala2roman/issues
Author-email: Sehan Dissanayake <sehandissanayake@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Sehan Dissanayake
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: nlp,phonetic,romanization,singlish,sinhala,sinhala-to-english,sinhala-unicode,text-processing,transliteration
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: twine>=4.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# sinhala2roman

[![PyPI version](https://img.shields.io/pypi/v/sinhala2roman.svg)](https://pypi.org/project/sinhala2roman/)
[![Python Version](https://img.shields.io/pypi/pyversions/sinhala2roman.svg)](https://pypi.org/project/sinhala2roman/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A lightweight, blazing-fast, and deterministic Sinhala reverse-transliteration Python library (**Sinhala native script → Romanized Sinhala / Singlish**).

---

## ✨ Features

- ⚡ **Ultra Fast & Lightweight:** Pure Python with **zero external dependencies** (~25,000+ words/sec).
- 🎯 **Deterministic Orthographic Baseline:** Clear, consistent, and predictable letter-by-letter / syllable mappings following standard Singlish conventions.
- 🛡️ **Robust Parsing & Fault Tolerant:** Handles Unicode normalization (NFC), zero-width joiners (`ZWJ`), conjuncts (*rakaransaya*, *yansaya*), and recovers gracefully from malformed repeated vowel signs.
- 🌐 **Mixed-Text Preservation:** Automatically preserves English text, punctuation, numbers, emojis, and `@mentions` unchanged.
- 💻 **Python API & CLI Support:** Use it directly in your Python code or from the terminal / command line.

---

## 📦 Installation

```bash
pip install sinhala2roman
```

---

## 🚀 Quick Start

### Python API

```python
from sinhala2roman import transliterate

# Basic transliteration
print(transliterate("සිංහල"))
# Output: sinhala

# Greetings and punctuation
print(transliterate("කොහොමද?"))
# Output: kohomada?

# Conjuncts (ZWJ / rakaransaya / yansaya)
print(transliterate("ශ්‍රී ලංකාව"))
# Output: shrii lankaawa

# Full sentences
print(transliterate("වෙසක් උත්සවයේදී බෞද්ධයින් අනුගමනය කරන පූජා විධි දෙක නම්,"))
# Output: wesak uthsawayeedii bauddhayin anugamanaya karana puujaa widhi deka nam,

# Mixed content (preserves English, numbers, symbols)
print(transliterate("@USER තුනක් ... 123!"))
# Output: @USER thunak ... 123!
```

### Command-Line Interface (CLI)

You can use `sinhala2roman` directly from your terminal:

```bash
# Pass text as arguments
sinhala2roman "සිංහල භාෂාව"
# Output: sinhala bhaashaawa

# Pipe text through standard input
echo "ශ්‍රී ලංකාව" | sinhala2roman
# Output: shrii lankaawa
```

---

## 📖 Mapping Reference

### Independent Vowels

| Sinhala | Latin | Sinhala | Latin | Sinhala | Latin |
|---|---|---|---|---|---|
| **අ** | a | **ඉ** | i | **උ** | u |
| **ආ** | aa | **ඊ** | ii | **ඌ** | uu |
| **ඇ** | ae | **ඍ** | ru | **ඎ** | ruu |
| **ඈ** | aae | **ඏ** | lu | **ඐ** | luu |
| **එ** | e | **ඒ** | ee | **ඓ** | ai |
| **ඔ** | o | **ඕ** | oo | **ඖ** | au |

### Consonants (Base)

| Sinhala | Latin | Sinhala | Latin | Sinhala | Latin | Sinhala | Latin |
|---|---|---|---|---|---|---|---|
| **ක** | k | **ට** | t | **ත** | th | **ප** | p |
| **ඛ** | kh | **ඨ** | th | **ථ** | th | **ඵ** | ph |
| **ග** | g | **ඩ** | d | **ද** | d | **බ** | b |
| **ඝ** | gh | **ඪ** | dh | **ධ** | dh | **භ** | bh |
| **ඞ** | ng | **ණ** | n | **න** | n | **ම** | m |
| **ඟ** | ng | **ඬ** | nd | **ඳ** | nd | **ඹ** | mb |
| **ච** | ch | | | | | **ය** | y |
| **ඡ** | chh | | | | | **ර** | r |
| **ජ** | j | | | | | **ල** | l |
| **ඣ** | jh | | | | | **ව** | w |
| **ඤ** | ny | | | | | **ශ** | sh |
| **ඥ** | gn | | | | | **ෂ** | sh |
| **ඦ** | ndj | | | | | **ස** | s |
| | | | | | | **හ** | h |
| | | | | | | **ළ** | l |
| | | | | | | **ෆ** | f |

*Note: In casual Singlish, retroflex/dental pairs (e.g. `ට`/`ත`, `ඩ`/`ද`, `ණ`/`න`, `ල`/`ළ`) and palatal/retroflex sibilants (`ශ`/`ෂ`) map to standard intuitive spellings (`t`, `d`, `n`, `l`, `sh`).*

### Dependent Vowel Signs (*Pilla*)

| Sinhala | Latin | Sinhala | Latin | Sinhala | Latin |
|---|---|---|---|---|---|
| **ා** | aa | **ි** | i | **ු** | u |
| **ැ** | ae | **ී** | ii | **ූ** | uu |
| **ෑ** | aae | **ෘ** | ru | **ෲ** | ruu |
| **ෙ** | e | **ේ** | ee | **ෛ** | ai |
| **ො** | o | **ෝ** | oo | **ෞ** | au |
| **ෟ** | ow | **ෳ** | luu | **්** | *(cancels inherent vowel)* |

### Special Signs

| Sinhala | Latin | Sign Name |
|---|---|---|
| **ං** | n | Anusvaraya (nasalization) |
| **ඃ** | h | Visargaya |

---

## 🛠️ Development & Testing

Clone the repository and install development dependencies:

```bash
git clone https://github.com/sehan-dissanayake/sinhala2roman.git
cd sinhala2roman

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest
```

---

## 📄 License

This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.

---

## 👤 Author

**Sehan Dissanayake**
- GitHub: [@sehan-dissanayake](https://github.com/sehan-dissanayake)
