def get_custom_classifier( text, category ): api_key = get_api_key() if type( category ) == dict: category = json.dumps( category ) response = requests.post( "https://apis.paralleldots.com/v4/custom_classifier", data= { "api_key": api_key, "text": text, "category": category } ).text response = json.loads( response ) return response
def get_usage(): api_key = get_api_key() if api_key == None or api_key == "": return { "Error": "API Key cannot be None or an empty String." } response = requests.post( "https://apis.paralleldots.com/usage", data= { "api_key": api_key } ).text response = json.loads( response ) return response
def get_keywords(text): apikey = get_api_key() if not apikey == None: if type(text) != str: return "Input must be a string." elif text == "": return "Input string cannot be empty." url = 'http://apis.paralleldots.com/keywords' headers = { 'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", 'cache-control': "no-cache", 'postman-token': "0cfb19ac-fb10-e41f-7893-0a9607ec0a2d" } payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"q\"\r\n\r\n%s\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"apikey\"\r\n\r\n%s\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--" % ( text, apikey) response = requests.request("POST", url, data=payload, headers=headers) if response.status_code != 200: return "Oops something went wrong ! You can raise an issue at https://github.com/ParallelDots/ParallelDots-Python-API/issues." response = {"keywords": json.loads(response.text)} response[ "usage"] = "By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions" return response else: return "API key does not exist"
def get_abuse(text): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/abuse", params={ "api_key": api_key, "text": text }).text response = json.loads(response) return response
def get_batch_keywords(data): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/keywords_batch", params={ "data": json.dumps(data), "api_key": api_key }).text response = json.loads(response) return response
def get_nsfw_url(url): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/nsfw", params={ "api_key": api_key, "url": url }).text response = json.loads(response) return response
def get_popularity_url(url): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/popularity", data={ "api_key": api_key, "url": url }).text response = json.loads(response) return response
def get_batch_emotion(data): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/emotion_batch", data={ "text": json.dumps(data), "api_key": api_key }).text response = json.loads(response) return response
def get_taxonomy(text): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/taxonomy", data={ "api_key": api_key, "text": text }).text response = json.loads(response) return response
def get_facial_emotion_url(url): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/facial_emotion", data={ "api_key": api_key, "url": url }).text response = json.loads(response) return response
def get_phrase_extractor(text): api_key = get_api_key() response = requests.post( "https://apis.paralleldots.com/v3/phrase_extractor", data={ "api_key": api_key, "text": text }).text response = json.loads(response) return response
def get_taxonomy(s1): apikey = get_api_key() if not apikey == None: params = {"sentence1": s1, "apikey": apikey} en_params = urllib.urlencode(params) url = "http://apis.paralleldots.com/taxonomy?" + en_params r = http.request("GET", url) return json.loads(r.data) else: return "API key does not exist"
def get_ner(s1): apikey = get_api_key() if not apikey == None: params = { 'sentence1' : s1, 'apikey' : apikey} en_params = urllib.urlencode(params) url = 'http://apis.paralleldots.com/ner?'+en_params r = http.request('GET',url) return json.loads(r.data) else: return "API key does not exist"
def get_batch_sarcasm(data, lang_code="en"): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v4/sarcasm_batch", data={ "text": json.dumps(data), "api_key": api_key, "lang_code": lang_code }).text response = json.loads(response) return response
def get_language_detection(text): api_key = get_api_key() response = requests.post( "https://apis.paralleldots.com/v3/language_detection", data={ "api_key": api_key, "text": text }).text response = json.loads(response) return response
def get_batch_phrase_extractor(data): api_key = get_api_key() response = requests.post( "https://apis.paralleldots.com/v4/phrase_extractor_batch", data={ "text": json.dumps(data), "api_key": api_key }).text response = json.loads(response) return response
def get_sentiment(text, lang_code="en"): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/sentiment", params={ "api_key": api_key, "text": text, "lang_code": lang_code }).text response = json.loads(response) return response
def get_similarity(text_1, text_2): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/similarity", data={ "api_key": api_key, "text_1": text_1, "text_2": text_2 }).text response = json.loads(response) return response
def get_emotion(text, lang_code="en"): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/emotion", data={ "api_key": api_key, "text": text, "lang_code": lang_code }).text response = json.loads(response) return response
def get_object_recognizer_url(url): api_key = get_api_key() response = requests.post( "https://apis.paralleldots.com/v3/object_recognizer", data={ "api_key": api_key, "url": url }).text response = json.loads(response) return response
def get_facial_emotion(path): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/facial_emotion", data={ "api_key": api_key }, files={ "file": open(path, "rb").read() }).text response = json.loads(response) return response
def get_batch_target_sentiment(data, entity): api_key = get_api_key() response = requests.post( "https://apis.paralleldots.com/v4/target/sentiment_batch", data={ "text": json.dumps(data), "api_key": api_key, "entity": entity }).text response = json.loads(response) return response
def get_target_sentiment(text, entity): api_key = get_api_key() response = requests.post( "https://apis.paralleldots.com/v4/target/sentiment", data={ "api_key": api_key, "text": text, "entity": entity }).text response = json.loads(response) return response
def get_usage(): api_key = get_api_key() if not api_key == None: url = "http://apis.paralleldots.com/usage" r = requests.post( url, params={ "api_key": api_key } ) if r.status_code != 200: return { "Error": "Oops something went wrong ! You can raise an issue at https://github.com/ParallelDots/ParallelDots-Python-API/issues." } r = json.loads( r.text ) return r else: return { "Error": "API Key not set." }
def get_nsfw(path): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v3/nsfw", params={ "api_key": api_key }, files={ "file": open(path, "rb").read() }).text response = json.loads(response) return response
def get_popularity(path): api_key = get_api_key() response = requests.post("https://apis.paralleldots.com/v4/popularity", data={ "api_key": api_key }, files={ "file": open(path, "rb").read() }).text response = json.loads(response) return response
def get_hit_count(): apikey = get_api_key() if not apikey == None: url = "http://apis.paralleldots.com/hit_count" r = requests.post(url, params={"apikey": apikey}) if r.status_code != 200: return "Oops something went wrong ! You can raise an issue at https://github.com/ParallelDots/ParallelDots-Python-API/issues." r = json.loads(r.text) r["usage"] = "By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions" return r else: return "API key does not exist"
def get_object_recognizer(path): api_key = get_api_key() response = requests.post( "https://apis.paralleldots.com/v3/object_recognizer", data={ "api_key": api_key }, files={ "file": open(path, "rb").read() }).text response = json.loads(response) return response
def get_abuse( text ): api_key = get_api_key() if not api_key == None: if type( text ) != str: return "Input must be a string." elif text in [ "", None ]: return "Input string cannot be empty." url = "http://apis.paralleldots.com/v2/abuse" r = requests.post( url, params={ "api_key": api_key, "text": text } ) if r.status_code != 200: return "Oops something went wrong ! You can raise an issue at https://github.com/ParallelDots/ParallelDots-Python-API/issues." r = json.loads( r.text ) return r else: return "API key does not exist"
def get_similarity( text_1, text_2 ): api_key = get_api_key() if not api_key == None: if type( text_1 ) != str or type( text_2 ) != str: return { "Error": "Input must be a string." } elif text_1 == "" or text_2 == "": return { "Error": "Input string cannot be empty." } url = "http://apis.paralleldots.com/v2/similarity" r = requests.post( url, params={ "api_key": api_key, "text_1": text_1, "text_2": text_2 } ) if r.status_code != 200: return { "Error": "Oops something went wrong ! You can raise an issue at https://github.com/ParallelDots/ParallelDots-Python-API/issues." } r = json.loads( r.text ) return r else: return { "Error": "API key does not exist" }
def get_intent(text): apikey = get_api_key() if not apikey == None: if type(text) != str: return "Input must be a string." elif text in ["", None]: return "Input string cannot be empty." url = "http://apis.paralleldots.com/intent" r = requests.post(url, params={"apikey": apikey, "text": text}) if r.status_code != 200: return "Oops something went wrong ! You can raise an issue at https://github.com/ParallelDots/ParallelDots-Python-API/issues." r = json.loads(r.text) r["usage"] = "By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions" return r else: return "API key does not exist"
def get_sentiment(s1): apikey = get_api_key() if not apikey == None: return "SENTIMENT API is currently underconstruction. You will be notified via email once it is up." else: return "API key does not exist"