|
|
|
@ -196,27 +196,27 @@ def ulca_api():
|
|
|
|
|
@app.route('/romanize', methods=['POST'])
|
|
|
|
|
def romanizeHandler():
|
|
|
|
|
langCodeLookup = {
|
|
|
|
|
"as": "as",
|
|
|
|
|
"bn": "bn",
|
|
|
|
|
"gom": "gom",
|
|
|
|
|
"gu": "gu",
|
|
|
|
|
"hi": "hi",
|
|
|
|
|
"kn": "kn",
|
|
|
|
|
"mai": "mai",
|
|
|
|
|
"ml": "ml",
|
|
|
|
|
"mni-Mtei": "mni",
|
|
|
|
|
"bn": "bn",
|
|
|
|
|
"mr": "mr",
|
|
|
|
|
"ne": "ne",
|
|
|
|
|
"or": "or",
|
|
|
|
|
"pa": "pa",
|
|
|
|
|
"sd": "sd",
|
|
|
|
|
"ta": "ta",
|
|
|
|
|
"te": "te",
|
|
|
|
|
"kn": "kn",
|
|
|
|
|
"ml": "ml",
|
|
|
|
|
"or": "or",
|
|
|
|
|
"gu": "gu",
|
|
|
|
|
"ur": "ur",
|
|
|
|
|
"as": "as",
|
|
|
|
|
"pa": "pa",
|
|
|
|
|
"mai": "mai",
|
|
|
|
|
"ne": "ne",
|
|
|
|
|
"gom": "gom",
|
|
|
|
|
"tcy": "kn", # Tulu uses Kannada script
|
|
|
|
|
"awa": "hi", # Awadhi uses Hindi script
|
|
|
|
|
"doi": "hi", # Dogri uses Hindi script
|
|
|
|
|
"bho": "hi", # Bhojpuri uses Hindi script
|
|
|
|
|
"doi": "hi", # Dogri uses Hindi script
|
|
|
|
|
"mni-Mtei": "mni",
|
|
|
|
|
"sd": "sd",
|
|
|
|
|
"awa": "hi", # Awadhi uses Hindi script
|
|
|
|
|
}
|
|
|
|
|
rtv = dict()
|
|
|
|
|
|
|
|
|
@ -224,6 +224,7 @@ def romanizeHandler():
|
|
|
|
|
|
|
|
|
|
# Check if database contains the romanizations already
|
|
|
|
|
englishWord = data['en']
|
|
|
|
|
rtv["en"] = englishWord
|
|
|
|
|
print(englishWord)
|
|
|
|
|
con = sqlite3.connect("../translations.db")
|
|
|
|
|
cur = con.cursor()
|
|
|
|
@ -234,7 +235,7 @@ def romanizeHandler():
|
|
|
|
|
romanizationsDict = []
|
|
|
|
|
if len(romanizations) > 0:
|
|
|
|
|
for row in romanizations:
|
|
|
|
|
row_dict = {columnNames[i]: row[i] for i in range(len(columns))}
|
|
|
|
|
row_dict = {columnNames[i]: row[i] for i in range(len(langCodeLookup)+1)} # The '+1' is because of English, which isn't in langCodeLookup
|
|
|
|
|
romanizationsDict.append(row_dict)
|
|
|
|
|
json_data = json.dumps(romanizationsdata, indent=4)
|
|
|
|
|
print(json_data)
|
|
|
|
@ -250,6 +251,9 @@ def romanizeHandler():
|
|
|
|
|
rtv[key] = responseJson['result']
|
|
|
|
|
|
|
|
|
|
rtvJson = jsonify(rtv)
|
|
|
|
|
rtv["en"] = englishWord
|
|
|
|
|
cur.execute("INSERT INTO romanizations VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", tuple(rtv.values()))
|
|
|
|
|
con.commit()
|
|
|
|
|
|
|
|
|
|
con.close()
|
|
|
|
|
return rtvJson
|
|
|
|
|