Created
March 19, 2015 05:12
-
-
Save trhura/e5d714737b7b3443ce21 to your computer and use it in GitHub Desktop.
script to convert burmese syllables to ipa symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
def get_ipa (syllable): | |
ipa = '' | |
ipa += get_cons_ipa(syllable) | |
ipa += get_medial_ipa(syllable) | |
ipa += get_vowel_ipa (syllable) | |
if u"\u028A" in ipa: | |
# remove `w` if there is upsilons | |
if "ြ" in syllable or "ျ" in syllable: | |
ipa = ipa.replace('w', 'j') | |
else: | |
ipa = ipa.replace('w', '') | |
return ipa | |
def get_cons_ipa (syllable): | |
cons_symbols = { | |
'က' : 'k', | |
'ခ' : 'kʰ', | |
'ဂ' : 'ɡ', | |
'ဃ' : 'ɡ', | |
'င' : 'ŋ', | |
'စ' : 's', | |
'ဆ' : 'sʰ', | |
'ဇ' : 'z', | |
'ဈ' : 'z', | |
'ဉ' : 'ɲ', | |
'ည' : 'ɲ', | |
'ဋ' : 't', | |
'ဌ' : 'tʰ', | |
'ဍ' : 'd', | |
'ဎ' : 'd', | |
'ဏ' : 'n', | |
'တ' : 't', | |
'ထ' : 'tʰ', | |
'ဒ' : 'd', | |
'ဓ' : 'd', | |
'န' : 'n', | |
'ပ' : 'p', | |
'ဖ' : 'pʰ', | |
'ဗ' : 'b', | |
'ဘ' : 'b', | |
'မ' : 'm', | |
'ယ' : 'j', | |
'ရ' : 'j', | |
'လ' : 'l', | |
'ဝ' : 'w', | |
'သ' : 'θ', | |
'ဟ' : 'h', | |
'ဠ' : 'l', | |
'အ' : 'ʔ' | |
} | |
cons = syllable[0] | |
return cons_symbols.get(cons, syllable[0]) | |
def get_medial_ipa(syllable): | |
ipa = "" | |
if "ှ" in syllable: | |
ipa += u"\u0325" | |
if "ွ" in syllable: | |
ipa += "w" | |
elif "ြ" in syllable or "ျ" in syllable: | |
ipa += "j" | |
return ipa | |
def get_vowel_ipa (syllable): | |
vowels_symbols = { | |
'' : '#', #'a̰', | |
'ာ' : 'à', | |
'ား' : 'á', | |
'်' : 'ɛʔ', | |
'င်' : 'ɪ̀ɴ', | |
'င့်' : 'ɪ̰ɴ', | |
'င်း' : 'ɪ́ɴ', | |
'စ်' : 'ɪʔ', | |
'ည်' : 'ì', | |
'ဉ်' : 'ɪ̀ɴ', | |
'ည့်' : 'ḭ', | |
'ဉ့်' : 'ɪ̰ɴ', | |
'ည်း' : 'í', | |
'ဉ်း' : 'ɪ́ɴ', | |
'တ်' : 'aʔ', | |
'န်' : 'àɴ', | |
'န့်' : 'a̰ɴ', | |
'န်း' : 'áɴ', | |
'ပ်' : 'aʔ', | |
'မ်' : 'àɴ', | |
'မ့်' : 'a̰ɴ', | |
'မ်း' : 'áɴ', | |
'ယ်' : 'ɛ̀', | |
'ံ' : 'àɴ', | |
'ံ့' : 'a̰ɴ', | |
'ံး' : 'áɴ', | |
'ိ' : 'ḭ', | |
'ိတ်' : 'eɪʔ', | |
'ိန်' : 'èɪɴ', | |
'ိန့်' : 'ḛɪɴ', | |
'ိန်း' : 'éɪɴ', | |
'ိပ်' : 'eɪʔ', | |
'ိမ်' : 'èɪɴ', | |
'ိမ့်' : 'ḛɪɴ', | |
'ိမ်း' : 'éɪɴ', | |
'ိံ' : 'èɪɴ', | |
'ိံ့' : 'ḛɪɴ', | |
'ိံး' : 'éɪɴ', | |
'ီ' : 'ì', | |
'ီး' : 'í', | |
'ု' : 'ṵ', | |
'ုတ်' : 'oʊʔ', | |
'ုန်' : 'òʊɴ', | |
'ုန့်' : 'o̰ʊɴ', | |
'ုန်း' : 'óʊɴ', | |
'ုပ်' : 'oʊʔ', | |
'ုမ်' : 'òʊɴ', | |
'ုမ့်' : 'o̰ʊɴ', | |
'ုမ်း' : 'óʊɴ', | |
'ုံ' : 'òʊɴ', | |
'ုံ့' : 'o̰ʊɴ', | |
'ုံး' : 'óʊɴ', | |
'ူ' : 'ù', | |
'ူး' : 'ú', | |
'ေ' : 'è', | |
'ေ့' : 'ḛ', | |
'ေး' : 'é', | |
'ဲ' : 'ɛ́', | |
'ဲ့' : 'ɛ̰', | |
'ော' : 'ɔ́', | |
'ော်' : 'aʊʔ', | |
'ောင်' : 'àʊɴ', | |
'ောင့်' : 'a̰ʊɴ', | |
'ောင်း' : 'áʊɴ', | |
'ော့' : 'ɔ̰', | |
'ော်' : 'ɔ̀', | |
'ို' : 'ò', | |
'ို်' : 'aɪʔ', | |
'ိုင်' : 'àɪɴ', | |
'ိုင့်' : 'a̰ɪɴ', | |
'ိုင်း' : 'áɪɴ', | |
'ို့' : 'o̰', | |
'ိုး' : 'ó', | |
#FIXME | |
'ွတ်' : 'ʊʔ', | |
'ွန်' : 'ʊ̀ɴ', | |
'ွန့်' : 'ʊ̰ɴ', | |
'ွန်း' : 'ʊ́ɴ', | |
'ွပ်' : 'ʊʔ', | |
'ွမ်' : 'ʊ̀ɴ', | |
'ွမ့်' : 'ʊ̰ɴ', | |
} | |
for v in sorted(vowels_symbols, key=len, reverse=True): | |
if v in syllable: | |
return vowels_symbols[v] | |
return "" | |
def main(): | |
with open ('ipa-syllables', 'r') as iFile: | |
for line in iFile: | |
syllable = line.strip() | |
print(syllable, '\t', get_ipa(syllable)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment