Commit 21e0125f by Sherif

nothing that important here but had to push before I wipe the hard drive

parent 9da91be9
Showing with 14 additions and 17 deletions
## musta3rab
# musta3rab
---
#### Simple-ish, easily moddable tool to Romanize Arabic text; for example, processing "أُستاذ" into "ʼustāḏ".
### Simple-ish, easily moddable tool to Romanize Arabic text; for example, processing "أُستاذ" into "ʼustāḏ".
* Uses the Hans Wehr romanization system by default, but can be extended using dictionaries.
* Licensed with [the Unlicense](http://unlicense.org/UNLICENSE), so feel free to steal it.
### How to & Documentation
## How to & Documentation
1. Launch in Python console
2. Use function
perstr("حاجة_بالعربي")
perstr("حاجة_بالعربي")
to return the romanization of حاجة\_بالعربي,
to return the romanization of حاجة\_بالعربي, or use
Or, use
perstr("حاجة_بالعربي", dictionary)
perstr("حاجة_بالعربي", dictionary)
to return the romanization of حاجة\_بالعربي according to the system instructed by _dictionary_.
#### Issues:
### Issues:
* Currently depends on having the right diacritical marks to return short vowels properly, and will not detect vowels not explicitly written
* See to-do list
#### To do:
### To do:
* Some kind of GUI
* Integrate parts of Taha Zerrouki's [Mishkal](https://github.com/linuxscout/mishkal) to fix short vowel representation to some extent, or otherwise fix it somehow
* Make it easier to add user dictionaries
......
#Last updated Oct 11, 2016.
#Last lines in function editdict contain some unfinished functionality commented out.
#Last lines in function editDict contain some unfinished functionality commented out.
#~Sherif
wehr = { #Dictionary using the Hans-Wehr transliteration system.
......@@ -69,9 +69,9 @@ wehr = { #Dictionary using the Hans-Wehr transliteration system.
# '': '',
}
skip = False
skip = False #this is used by editDict to skip certain parts of the input for any reason.
def editdict (c, ara, i, table):
def editDict (c, ara, i, table):
global skip
#function to dynamically edit the dictionary as needed to avoid poops.
if ( c not in table ):
......@@ -88,18 +88,17 @@ def editdict (c, ara, i, table):
skip = True
if ( ara[i] == 'ِ' and ara[i+1] == 'ي' ):
skip = True
#If a diacritic is followed by a long vowel of the same sound,
#the diacritic is skipped.
#If a diacritic is followed by a long vowel of the same sound, the diacritic is skipped.
# if ( ara[i] == 'ا' and ara[i+1] == 'ل' ):
# if table == wehr:
def perstr(ara, table = wehr):
def romanize(ara, table = wehr):
global skip
#ara is the string to be romanized, table is the dict used (Wehr by default).
rom = ""
for i in range ( 0, len(ara) ):
skip = False
editdict(ara[i], ara, i, table)
editDict(ara[i], ara, i, table)
if skip is True:
continue
rom += table[ ara[i] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment