Skip to content

Commit

Permalink
Changing UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinodh Rajan committed May 20, 2022
1 parent f134548 commit fab0acc
Show file tree
Hide file tree
Showing 121 changed files with 615,519 additions and 6,603 deletions.
68 changes: 62 additions & 6 deletions aksharamukha-back/generateJSON.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import itertools
import os
from aksharamukha.transliterate import convert, unique_everseen, removeA
from aksharamukha import transliterate

# Script Mapping JSON

Expand Down Expand Up @@ -102,10 +103,63 @@ def generate_script_matrix():
f.write(json.dumps(results_final, ensure_ascii = False, sort_keys=True, indent=4))
f.close()

def semiticListTransliterate(charlist, script2, fix=''):
results = {}

results['Latn'] = charlist.replace('،',',').split(',')
results['script2'] = transliterate.process('Latn', script2, charlist, nativize=False).replace('،',',').split(',')
results['script2R'] = transliterate.process(script2, 'Latn', transliterate.process('Latn', script2, charlist, nativize=False))\
.replace('،',',').split(',')

results['script2G'] = transliterate.process('Brahmi', script2, transliterate.process('Latn', 'Brah', charlist))\
.replace('،',',').split(',')
results['script2GR'] = transliterate.process('Brah', 'Latn', transliterate.process('Latn', 'Brah', charlist))\
.replace('،',',').split(',')

for script in GM.SemiticScripts:
if script != 'Latn' and script != 'Arab-Ph' and script != 'Arab-Ga':
#print(script)
results[script] = transliterate.process('Latn', script, charlist, nativize=False)\
.replace('،',',').split(',')
results[script + 'R'] = transliterate.process(script, 'Latn', \
transliterate.process('Latn', script, charlist, nativize=False), nativize=False)\
.replace('،',',').split(',')

if fix == 'alephA':
results['script2R'][0] = 'ʾ'
elif fix == 'inherentA':
results['script2R'][0] += 'a'

return results

# generate semitic matrix
def generate_semitic_matrix():
charlistCore = 'ʾ, b, g, d, h, w, z, ḥ, ṭ, y, k, l, m, n, s, ʿ, p, ṣ, q, r, š, t'.replace(' ', '')

charAdditional = 'ḍ, ḏ, ḫ, ġ, ṯ, ẓ, v, f, č, j, ž, ɖ, ʈ, ʂ, ɭ, ɲ, ɳ, ɽ, p̣, kʰ, gʰ, čʰ, jʰ, ʈʰ, ɖʰ, tʰ, dʰ, pʰ, bʰ, ɽʰ, ʔ, ˀy, ˀw'.replace(' ', '')

charInitVowels = 'â, ā̂, î, ī̂, û, ū̂, ê, ē̂, ô, ō̂, âŵ, âŷ, ˀâ, ˀî'.replace(' ', '')

charlistVowels = 'la, lā, li, lī, lu, lū, le, lē, lo, lō, l꞉, l̽, lă, lĕ, lŏ, laŷ, laŵ, la̮, lā̮, laⁿ, luⁿ, liⁿ'.replace(' ', '')

for script2 in GM.IndicScripts:
print('Semitic matrix with', script2)
resultsAll = {}
resultsAll['core'] = semiticListTransliterate(charlistCore, script2, fix='alephA')
resultsAll['adds'] = semiticListTransliterate(charAdditional, script2)
resultsAll['initvows'] = semiticListTransliterate(charInitVowels, script2)
resultsAll['vows'] = semiticListTransliterate(charlistVowels, script2, fix='inherentA')


f = io.open("resources/semitic_matrix/semitic_matrix_" + script2 + ".json", mode="w", encoding="utf-8")
f.write(json.dumps(resultsAll, ensure_ascii = False, sort_keys=True, indent=4))
f.close()


## Generate Syllables
def generate_syllables():
results = {}
scripts_syllabary = ["Kaithi", "Makasar", "Nandinagari"]
scripts_syllabary = ["Kaithi"]

k = 0
for script1 in scripts_syllabary:
Expand Down Expand Up @@ -222,7 +276,7 @@ def generate_conjuncts():
conj = '{"conjuncts1S1":["ak","akh","ag","agh","aṅ","ac","ach","aj","ajh","añ","aṭ","aṭh","aḍ","aḍh","aṇ","at","ath","ad","adh","an","ap","aph","ab","abh","am","ay","ar","al","av","aś","aṣ","as","ah","al̤"],"conjuncts2S1":["kka","kkha","kca","kcha","kṇa","kta","ktha","kna","kpa","kpha","kma","kya","kra","kla","kva","kśa","kṣa","ksa","khkha","khna","khya","khva","gga","ggha","gja","gḍa","gṇa","gda","gdha","gna","gba","gbha","gma","gya","gra","gla","gva","ghna","ghma","ghya","ghra","ghva","ṅka","ṅkha","ṅga","ṅgha","ṅṅa","ṅca","ṅja","ṅta","ṅda","ṅdha","ṅna","ṅpa","ṅbha","ṅma","ṅya","ṅra","ṅva","ṅśa","ṅsa","ṅha","cca","ccha","cña","cma","cya","cra","cva","chya","jja","jjha","jña","jma","jya","jra","jva","jha","jhña","cña","cha","ñja","ñjha","ñña","ñśa","ñha","ṭka","ṭkha","ṭca","ṭcha","ṭṭa","ṭṇa","ṭta","ṭpa","ṭpha","ṭma","ṭya","ṭva","ṭśa","ṭṣa","ṭsa","ṭhya","ḍga","ḍgha","ḍja","ḍḍa","ḍḍha","ḍda","ḍdha","ḍba","ḍbha","ḍma","ḍya","ḍra","ḍla","ḍva","ḍhya","ḍhra","ḍhva","ṇṭa","ṇṭha","ṇḍa","ṇḍha","ṇṇa","ṇna","ṇma","ṇya","ṇva","ṇha","tka","tkha","tta","ttha","tna","tpa","tpha","tma","tya","tra","tva","tṣa","tsa","thna","thya","thra","thva","dga","dgha","dda","ddha","dna","dba","dbha","dma","dya","dra","dva","dhna","dhma","dhya","dhra","dhva","nka","nkha","nga","ngha","nta","ntha","nda","ndha","nna","npa","npha","nba","nbha","nma","nya","nra","nva","nṣa","nsa","nha","pka","pkha","pca","pcha","pṭa","pṇa","pta","pna","ppa","ppha","pma","pya","pra","pla","pva","pśa","psa","bga","bja","bda","bdha","bba","bbha","bya","bra","bla","bva","bhṇa","bhna","bhma","bhya","bhra","bhla","bhva","mṇa","mna","mpa","mpha","mba","mbha","mma","mya","mra","mla","mva","mha","yya","yva","rka","rka","hra","gra","gha","rca","rcha","rja","rja","hra","ṭra","ḍra","ḍha","rṇa","rta","rtha","rda","rdha","rna","rpa","rpha","rba","rbha","rma","rya","rla","rva","rśa","rṣa","rsa","rha","lka","lga","lda","lpa","lpha","lba","lbha","lma","lya","lla","lva","lśa","lha","vṇa","vna","vya","vra","vla","śca","ścha","śna","śpa","śma","śya","śra","śla","śva","śśa","ṣka","ṣkha","ṣṭa","ṣṭha","ṣṇa","ṣpa","ṣpha","ṣma","ṣya","ṣra","ṣva","ṣṣa","ska","skha","sta","stha","sna","spa","spha","sma","sya","sra","sva","ssa","hṇa","hna","hma","hya","hra","hla","hva","l̤ha"],"conjuncts3S1":["kkra","kkla","kkva","kkṣa","ktya","ktra","ktva","kthna","kthya","knya","kpra","kpla","kmya","krya","klya","kśma","kśra","kśla","kśva","kṣṇa","kṣma","kṣya","kṣra","kṣva","ksta","kstha","ksna","kspa","kspha","ksma","ksya","ksra","ksva","ggra","gghya","gghra","gjña","gjya","gjva","gdya","gdra","gdva","gdhya","gdhra","gdhva","gnya","gbra","gbhya","gbhra","gmya","grya","grva","gvya","gvra","ghnya","ghrya","ghvya","ṅkta","ṅktha","ṅkya","ṅkra","ṅkla","ṅkva","ṅkṣa","ṅksa","ṅkhya","ṅgdha","ṅgya","ṅgra","ṅgva","ṅghna","ṅghya","ṅghra","ṅtra","ṅtva","ṅdhya","ṅnya","ṅnra","ṅpra","ṅvya","ṅvra","ṅsva","ccya","cchma","cchya","cchra","cchla","cchva","cñya","jjña","jjya","jjva","jjhya","jñya","jñva","jmya","jrya","jvya","ñcma","ñcya","ñcva","ñchna","ñchya","ñchra","ñchla","ñchva","ñjña","ñjma","ñjya","ñjva","ñśma","ñśya","ñśra","ñśla","ñśva","ṭkra","ṭkṣa","ṭṭya","ṭtra","ṭtva","ṭpra","ṭśra","ṭśla","ṭsta","ṭstha","ṭsna","ṭspa","ṭsva","ḍgya","ḍgra","ḍghra","ḍjña","ḍjya","ḍḍhya","ḍḍhva","ḍdva","ḍbra","ḍbhya","ḍbhra","ḍvya","ṇṭya","ṇṭhya","ṇḍḍha","ṇḍya","ṇḍra","ṇḍva","ṇḍhya","ṇḍhra","ṇvya","tkya","tkra","tkla","tkva","tkṣa","tkhya","ttna","ttma","ttya","ttra","ttva","ttsa","tthya","tnya","tnva","tpra","tpla","tmya","tyva","trya","trva","tvya","tska","tskha","tsta","tstha","tsna","tspa","tspha","tsma","tsya","tsra","tsva","thnya","thvya","dgra","dgla","dghna","dghra","ddya","ddra","ddva","ddhma","ddhya","ddhra","ddhva","dbra","dbhya","dbhra","dbhva","dmya","drya","drva","dvya","dvra","dhnya","dhrya","dhvya","dhvra","nkra","nkla","nkva","nkṣa","nkhya","ngra","ngla","nghna","nghra","ntta","nttha","ntma","ntya","ntra","ntva","ntsa","nthya","nddha","ndma","ndya","ndra","ndva","ndhma","ndhya","ndhra","ndhva","nnya","nnva","npra","npla","npsa","nbra","nbhra","nmya","nmra","nmla","nyva","nvya","nvra","nska","nskha","nsta","nstha","nsna","nspa","nspha","nsma","nsya","nsra","nsva","nhya","nhra","nhva","pkṣa","ptya","ptra","ptva","pnya","ppra","prya","pśya","psna","psya","psva","bgra","bjya","bdya","bdhya","bdhva","bbra","bbhya","bvya","bhrya","bhrva","bhvya","mnya","mpya","mpra","mpla","mpsa","mbya","mbra","mbva","mbhya","mbhra","mmya","mmra","mmla","mrya","rkca","rkta","rktha","rkpa","rkya","rkṣa","rksa","rkhya","rgga","rggha","rgja","rgbha","rgya","rgra","rgla","rgva","rghna","rghya","rghra","rṅkha","rṅga","rccha","rcya","rjña","rjma","rjya","rjva","rñja","rḍya","rḍhya","rṇṇa","rṇya","rṇva","rtta","rtna","rtma","rtya","rtra","rtva","rtsa","rthya","rddha","rdma","rdya","rdra","rdva","rdhna","rdhma","rdhya","rdhra","rdhva","rnya","rnva","rpya","rbra","rbhya","rbhra","rbhva","rmya","rmra","rmla","ryya","rvya","rvra","rvla","rśma","rśya","rśva","rṣṭa","rṣṭha","rṣṇa","rṣma","rṣya","rṣva","rsra","rsva","rhya","rhra","rhla","rhva","lkya","lgva","lpya","lbya","lbhya","llya","lvya","lhya","vnya","ścya","śnya","śmya","śrya","śrva","śvya","ṣkya","ṣkra","ṣkla","ṣkva","ṣkṣa","ṣṭya","ṣṭra","ṣṭva","ṣṭhya","ṣṭhva","ṣṇya","ṣṇva","ṣpya","ṣpra","ṣpla","ṣmya","skra","stma","stya","stra","stva","stsa","sthna","sthya","snya","spra","sphya","smya","srya","svya","ssya","ssva","hnya","hmya","hvya"],"conjuncts4S1":["ktrya","ktvya","kṣṇya","kṣmya","kstra","gdvya","gdhrya","ṅktya","ṅktra","ṅktva","ṅkṣṇa","ṅkṣma","ṅkṣya","ṅkṣva","ṅgdhya","ṅgdhva","ṅghrya","tkṣma","tkṣva","ttrya","tstra","tsthya","tspra","tsphya","ddvya","nttva","ntrya","ntvya","ntsta","ntstha","ntsna","ntspa","ntsya","ntsra","ntsva","nddhya","nddhva","ndrya","ndvya","ndhrya","nstra","nsphya","ptrya","psnya","rkṣṇa","rkṣya","rksva","rṅgya","rjmya","rttra","rtnya","rtrya","rtvya","rtsna","rtsya","rddhya","rdrya","rdvya","rdhnya","rśvya","rṣṭya","rṣṇya","lgvya","ṣṭrya","strya","sthnya"],"conjuncts5S1":["rtsnya"]}'
vowels = ['a', 'ā', 'i', 'ī', 'u', 'ū', 'ṛ', 'ĕ', 'e', 'ai', 'ŏ', 'o', 'au', 'aṃ', 'aḥ']

scripts = ["Nandinagari", "Kaithi"]
scripts = ["Kaithi"]

total = len(scripts) * len(vowels)

Expand Down Expand Up @@ -329,14 +383,16 @@ def generate_common_letters():
f.close()

if __name__ == "__main__":
print('Generating Script Mapping as Json')
generate_script_map()
#print('Generating Script Mapping as Json')
#generate_script_map()
print('Generating Script Matrix')
generate_script_matrix()
#print('Generating Semitic Matrix')
#generate_semitic_matrix()
#print('Generating Syllabary')
generate_syllables()
#generate_syllables()
#print('Generating Conjuncts')
generate_conjuncts()
#generate_conjuncts()
#print('Generating Common Letters')
#generate_common_letters()

Expand Down
70 changes: 25 additions & 45 deletions aksharamukha-back/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,56 +399,15 @@ def describe_list():
results['script1hk'] = convert(request.json['script1'], 'HK', results['script1'], False,[],[])
return jsonify(results)

def semiticListTransliterate(charlist, script2, fix=''):
results = {}

results['Latn'] = charlist.replace('،',',').split(',')
results['script2'] = transliterate.process('Latn', script2, charlist, nativize=False).replace('،',',').split(',')
results['script2R'] = transliterate.process(script2, 'Latn', transliterate.process('Latn', script2, charlist, nativize=False))\
.replace('،',',').split(',')

results['script2G'] = transliterate.process('Brahmi', script2, transliterate.process('Latn', 'Brah', charlist))\
.replace('،',',').split(',')
results['script2GR'] = transliterate.process('Brah', 'Latn', transliterate.process('Latn', 'Brah', charlist))\
.replace('،',',').split(',')

for script in GeneralMap.SemiticScripts:
if script != 'Latn' and script != 'Arab-Ph' and script != 'Arab-Ga':
#print(script)
results[script] = transliterate.process('Latn', script, charlist, nativize=False)\
.replace('،',',').split(',')
results[script + 'R'] = transliterate.process(script, 'Latn', \
transliterate.process('Latn', script, charlist, nativize=False), nativize=False)\
.replace('،',',').split(',')

if fix == 'alephA':
results['script2R'][0] = 'ʾ'
elif fix == 'inherentA':
results['script2R'][0] += 'a'

return results

@app.route('/api/semiticmatrix', methods=['POST', 'GET'])
def character_matrix_semitic():
semitic_json = get_semitic_json()

charlistCore = 'ʾ, b, g, d, h, w, z, ḥ, ṭ, y, k, l, m, n, s, ʿ, p, ṣ, q, r, š, t'.replace(' ', '')

charAdditional = 'ḍ, ḏ, ḫ, ġ, ṯ, ẓ, v, f, č, j, ž, ɖ, ʈ, ʂ, ɭ, ɲ, ɳ, ɽ, p̣, kʰ, gʰ, čʰ, jʰ, ʈʰ, ɖʰ, tʰ, dʰ, pʰ, bʰ, ɽʰ, ʔ, ˀy, ˀw'.replace(' ', '')

charInitVowels = 'â, ā̂, î, ī̂, û, ū̂, ê, ē̂, ô, ō̂, âŵ, âŷ, ˀâ, ˀî'.replace(' ', '')

charlistVowels = 'la, lā, li, lī, lu, lū, le, lē, lo, lō, l꞉, l̽, lă, lĕ, lŏ, laŷ, laŵ, la̮, lā̮, laⁿ, luⁿ, liⁿ'.replace(' ', '')

script2 = request.json['script2']

resultsAll = {}
resultsAll['core'] = semiticListTransliterate(charlistCore, script2, fix='alephA')
resultsAll['adds'] = semiticListTransliterate(charAdditional, script2)
resultsAll['initvows'] = semiticListTransliterate(charInitVowels, script2)
resultsAll['vows'] = semiticListTransliterate(charlistVowels, script2, fix='inherentA')
f = open ('resources/semitic_matrix/semitic_matrix_' + script2 + '.json', 'r', encoding='utf-8')
results_final = json.loads(f.read())
f.close()

return jsonify(resultsAll)
return jsonify(results_final)

@app.route('/api/describesemitic', methods=['POST', 'GET'])
def describe_list_semitic():
Expand Down Expand Up @@ -627,6 +586,27 @@ def convert_post():

return text

@app.route('/api/convert_xml', methods=['POST', 'GET'])
def convert_xml():
import copy
from lxml import etree

if 'text' in request.json:
parser = etree.XMLParser(ns_clean=True, remove_comments=True)
new_root = etree.fromstring(request.json['text'].encode("utf8"), parser)

#print(new_root.tag)

for el in new_root.iter():
#(el, el.text, type(el.text))
if el.text is not None:
el.text = convert(request.json['source'], request.json['target'], el.text, request.json['nativize'],
request.json['preOptions'], request.json['postOptions'])
else:
text = ''

return jsonify(etree.tostring(new_root, encoding='unicode'))


@app.route('/api/convert_loop_tgt', methods=['POST', 'GET'])
def convert_loop_tgt_post():
Expand Down
1 change: 1 addition & 0 deletions aksharamukha-back/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ langcodes>=3.1.0
language_data
regex>=2021.8.3
fonttools[unicode]>=4.31
lxml
google-python-cloud-debugger
Loading

0 comments on commit fab0acc

Please sign in to comment.