From 938d97a24b559699a95b54ef3c6f47e7731199ba Mon Sep 17 00:00:00 2001 From: Pruthwik Date: Tue, 26 Apr 2022 15:15:58 +0530 Subject: [PATCH] API Access --- .../run_sampark_shallow_parser.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Codes-For-API-and-Evaluation/run_sampark_shallow_parser.py diff --git a/Codes-For-API-and-Evaluation/run_sampark_shallow_parser.py b/Codes-For-API-and-Evaluation/run_sampark_shallow_parser.py new file mode 100644 index 0000000..8072ac4 --- /dev/null +++ b/Codes-For-API-and-Evaluation/run_sampark_shallow_parser.py @@ -0,0 +1,25 @@ +"""Run Sampark shallow parser.""" +# Language codes for passing onto the API, 3 lettered language identifier. +# Kannada - kan, Punjabi - pan, Urdu - urd, Telugu - tel, Hindi - hin +# if requests package is not there, do pip install requests +import requests +import json + + +url = "https://ssmt.iiit.ac.in/indic_shallow_parser_v1" + + +def main(): + """Pass arguments and call functions here.""" + text = "भारतीय भाषा अनुवाद प्रणाली।\nभारतीय भाषा अनुवाद प्रणाली।" + # for multiple sentences, just join them by \n + out = {"language":"hin", "text": text} + headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} + r = requests.post(url, data=json.dumps(out), headers=headers) + json_output = r.json() + ssf_sent = json_output['data'] + print(ssf_sent) + + +if __name__ == '__main__': + main() -- GitLab