You are here

Sample Source Code: ParallelDots Keyword Generator Comments

The ParallelDots Keyword Generator is a powerful tool with text analysis that can be used to index data, generate tag clouds and accelerate the searching time. It generates an extensive list of relevant keywords and phrases to make research more context focused.

This code sample is for use with the ParallelDots Keyword Generator API.

from paralleldots.config import get_api_key
import requests
import json

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 = '' 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" 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:" return response else: return "API key does not exist"