You are here

Sample Source Code: ParallelDots Text Classification (Taxonomy) Followers

ParallelDots Text Classification (Taxonomy) can help you understand customer behavior by categorizing conversations on social networks, feedback and other web sources.

Search engines, newspapers, or e-commerce portals categorize their content or products to facilitate the search and navigation.

This code sample is for use with the ParallelDots Text Classification (Taxonomy) API.

from paralleldots.config import get_api_key
import requests
import json

def get_taxonomy( sentence1 ): apikey = get_api_key() if not apikey == None: if type( sentence1 ) != str: return "Input must be a string." elif sentence1 == "": return "Input string cannot be empty." url = 'http://apis.paralleldots.com/taxonomy' r = requests.post( url, data=json.dumps( { "apikey": apikey, "sentence1": sentence1 } ) ) 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"