diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a2811f9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: python +python: + - "2.7" + + +# command to install dependencies +install: + - pip install . + +# command to run tests +script: echo foo diff --git a/paralleldots/abusive_content b/paralleldots/abusive_content new file mode 100644 index 0000000..93ef3ac --- /dev/null +++ b/paralleldots/abusive_content @@ -0,0 +1,29 @@ +from paralleldots.config import get_api_key + +import requests + +import json + + + +def get_abusive_content( 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/abuse" + + params = { "apikey": apikey, "text": text } + + + + #post call to abusive content detector + + r = requests.post( url, json.dumps(params)) + + + + 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"