Skip to main content

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/. the mehdie logo is a line-drawn M in several similar lines symbolizing the similarity and distincness of the middle-eastern languages)

MEHDIE is funded by the Israel Ministry of Science and Technology MOST. The symbol of the state of Israel, a Menora with two olive branches on the sides.)

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

translit_me-1.1.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

translit_me-1.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file translit_me-1.1.0.tar.gz.

File metadata

  • Download URL: translit_me-1.1.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for translit_me-1.1.0.tar.gz
Algorithm Hash digest
SHA256 756a11a92b506b9f4df3fc0c70d814b0c39219052e947186300aa1e218f587d1
MD5 894db2d657ead93af673ce244bdf3e74
BLAKE2b-256 4b41878e7fcd2b0a4a22f4f8015cd49a17f5bf8ae9d8a13ab48af32e69bd7229

See more details on using hashes here.

File details

Details for the file translit_me-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: translit_me-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for translit_me-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 569c5efbb03e18b3a2bb1b678218fd186f2bc60a55a8d5cca27b09d365dedfdd
MD5 3e394f77cef435ccd370421e4fd65660
BLAKE2b-256 637e9d30e4a3cc6e0d434f3ffda9412f01f48b692ec187f15b44faa6c4d9b08e

See more details on using hashes here.

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