You are here

Sample Source Code: ParallelDots Intent Analysis Comments

ParallelDots Intent Analysis tells whether the underlying intention behind a sentence is an opinion, news, marketing, complaint, suggestion, appreciation, or a query. The type of intention is returned is based on the ParallelDots proprietary data set.

This code sample is for use with the ParallelDots Intent Analysis API.


from paralleldots.config import get_api_key
import requests
import json

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"