Last active
June 28, 2018 20:20
-
-
Save aniketp/537af37d6c5ab2189579c1e83fd95c5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import time | |
import requests | |
from urllib.parse import urlencode, quote_plus | |
url = 'http://[SECRET]:8080/' | |
cliff_version = 'CLIFF-2.3.0' | |
text = 'There is an ongoing match at the Wembley Stadium in Britain for USA' | |
payload = {'q': text} | |
encoded_text = urlencode(payload, quote_via = quote_plus) | |
main_url = url + cliff_version + '/parse/text?' + encoded_text | |
start = time.time() | |
response = requests.get(main_url) | |
end = time.time() | |
data = json.loads(response.text) | |
pretty_data = json.dumps(data, indent=4, sort_keys=True) | |
print(pretty_data) | |
timediff = end - start | |
comptime = data["milliseconds"] / 1000 | |
print("total = " + str(timediff) + ' | ' + 'computation = ' + str(comptime)) | |
# Output: total = 0.7978863716125488 computation = 0.017 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment