From b2055b11d9a05359be57fbdd803ccd320829c948 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Wed, 12 Mar 2025 16:06:52 -0400 Subject: [PATCH] Fixed issues with fetching romanizations from DB --- xlit_server.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/xlit_server.py b/xlit_server.py index 4232433..4d0d632 100644 --- a/xlit_server.py +++ b/xlit_server.py @@ -201,8 +201,8 @@ def romanizeHandler(): "mr": "mr", "ta": "ta", "te": "te", - "kn": "kn", "ml": "ml", + "kn": "kn", "or": "or", "gu": "gu", "ur": "ur", @@ -218,6 +218,32 @@ def romanizeHandler(): "sd": "sd", "awa": "hi", # Awadhi uses Hindi script } + + lang2code = { + "hindi": "hi", + "bengali": "bn", + "marathi": "mr", + "tamil": "ta", + "telugu": "te", + "malayalam": "ml", + "kannada": "kn", + "oriya": "or", + "gujarati": "gu", + "urdu": "ur", + "assamese": "as", + "punjabi": "pa", + "maithili": "mai", + "nepali": "ne", + "konkani": "gom", + "tulu": "tcy", + "bhojpuri": "bho", + "dogri": "doi", + "manipuri": "mni-Mtei", + "sindhi": "sd", + "awadhi": "awa", + "english": "en", + } + rtv = dict() data = request.get_json(force=True) @@ -235,10 +261,11 @@ def romanizeHandler(): romanizationsDict = [] if len(romanizations) > 0: for row in romanizations: - row_dict = {columnNames[i]: row[i] for i in range(len(langCodeLookup)+1)} # The '+1' is because of English, which isn't in langCodeLookup + row_dict = {lang2code[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) + json_data = jsonify(romanizationsDict[0]) + con.close() + return json_data # if len(romanizations) != 0: # Assuming the romanizations didn't exist before