You are here

Sample Source Code: ParallelDots Multilingual Sentiment Analysis Comments

ParallelDots Multilingual Sentiment Analysis can help you understand the underlying tone of the message for sentences in French and Portuguese. Additional language support is planned in the future.

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

from paralleldots.config import get_api_key
import requests
import json

def get_multilang_sentiment( text, lang ): apikey = get_api_key() if not apikey == None: if type( text ) != str or type( lang ) != str: return "Input must be a string." elif text in [ "", None ] or lang in [ "", None ]: return "Input string cannot be empty." url = "" r = url, params={ "apikey": apikey, "text": text, "lang": lang } ) if r.status_code != 200: return "Oops something went wrong ! You can raise an issue at" 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:" return r else: return "API key does not exist"