From 8e50f5cc84e6d9c40579b27a2b600a4c3188373f Mon Sep 17 00:00:00 2001 From: souvik03-136 <66234771+souvik03-136@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:28:16 +0530 Subject: [PATCH] Update: app.py --- .idea/book-keeping-ai.iml | 6 ++++-- .idea/misc.xml | 5 ++++- app.py | 23 ++++++++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.idea/book-keeping-ai.iml b/.idea/book-keeping-ai.iml index d0876a7..3c72192 100644 --- a/.idea/book-keeping-ai.iml +++ b/.idea/book-keeping-ai.iml @@ -1,8 +1,10 @@ - - + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 28e801a..375cda6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ - + + + \ No newline at end of file diff --git a/app.py b/app.py index 7795418..31917a8 100644 --- a/app.py +++ b/app.py @@ -69,6 +69,27 @@ def extract_entities(): "ItemName": ItemName, "ItemQuantity": ItemQuantity }) +def convert_to_dml(input_text): + parsed_data = re.match(r'(.*)\s+less than\s+(\d+)\s+rs', input_text, re.IGNORECASE) + if parsed_data: + item = parsed_data.group(1).strip() + price = int(parsed_data.group(2)) + return f"SELECT {item} FROM Products WHERE Price < {price};" + else: + return "Invalid input format. Please provide something like 'apples less than 50 rs'." + + +@app.route('/convert_to_dml', methods=['POST']) +def convert_to_dml_endpoint(): + data = request.json + input_text = data.get('text', '') + + dml_code = convert_to_dml(input_text) + + return jsonify({ + "input_text": input_text, + "dml_code": dml_code + }) if __name__ == '__main__': - app.run(debug=True) + app.run(debug=True) \ No newline at end of file