A transliteration service for Middle-Eastern languages.
Project description
The MEHDIE Transliteration Service and Python Package
This repository contains the source code for the MEHDIE Transliteration Service and Python package. The service is a RESTful API that can be used to transliterate names between Hebrew, Arabic and Latin characters. The Python package provides a Python interface to the service.
The service was developed as part of the MEHDIE project- https://mehdie.org/. )
MEHDIE is funded by the Israel Ministry of Science and Technology MOST. )
Installation
You can use the Dockerfile and cloudbuild yaml file to deploy to a cloud run service or you can use the python package to use the service in your own code.
Usage
Python Package - Transliteration
import unittest
from translit_me.transliterator import transliterate as tr
from translit_me.lang_tables import *
class TestTransliterate(unittest.TestCase):
def test_hebrew_arabic(self):
names = ['נועַם', "מאנץ'", "בישינה", "דימונה"]
expected = ['نوعَم', 'مانض', 'بيشينة', 'بيسينة', 'ديمونة', 'ضيمونة']
res = tr(names, HE_AR)
print(res)
self.assertListEqual(res, expected)
More examples can be found in the tests folder.
RESTful API
The service is a RESTful API that can be used to transliterate names between Hebrew, Arabic and Latin characters.
import requests
def transliterate_service(to_transliterate: list,from_lang: str,to_lang: str):
"""
This method invokes a cloud run service to transliterate a list of strings
(e.g., ['نوعم', 'مانض', 'پيشينة'])
from the from_lang (e.g., 'ar') to the to_lang (e.g., 'en').
Supported languages: ('he','ar','en'). Anything non 'he'/'ar' will be treated
as 'en'
"""
url = 'https://hebrew-transliteration-service-snlwejaxvq-ez.a.run.app/'
args = {'from_lang': from_lang, 'to_lang': to_lang, 'data': to_transliterate}
x = requests.post(url, json=args)
res_list = x.json()['transliterations']
return res_list
names = ["תִפְלִיס","תַרְג'","תַרוּג'ה"]
from_language = 'he'
to_language = 'ar'
transliterate_service(names, from_language, to_language)
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
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 translit_me-1.3.tar.gz.
File metadata
- Download URL: translit_me-1.3.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5255edc6201d82274532f0b7cfeb4a84813a704fcccdc094d216c6e12405f0a
|
|
| MD5 |
cbe545f25f43f688e738da037ab7f7ee
|
|
| BLAKE2b-256 |
704ca26ef137a47679cf3b9b70e7307f42a225bc6e09feb7a27dfb4799444602
|
File details
Details for the file translit_me-1.3-py3-none-any.whl.
File metadata
- Download URL: translit_me-1.3-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac97b108417444d36b644db3aeea6a617754ad438e600c139e906e989ba1017e
|
|
| MD5 |
3a60435fb0c10c13b61c516f71dc0c50
|
|
| BLAKE2b-256 |
fda445a1e93106e9d52f51aaa0187666e4c900922c6580bb2ca18403caf135e0
|