Word Cloud Generator
This endpoint will generate an SVG image containing the top 200 most used words in the text you used as input.
Before generating the world cloud, we first remove stop words [1] or filler words, then lemmatize [2] each word and reduce it to its purest form, and finally count the number of times in appears in the text.
[1] stop words or filler words, are words that appear too often in most texts and that don't add much content to the meaning of that text. For example:
I
,the
,a
,in
,on
, etc.[2] lemmatization is the process of turning words altered by conjugation, pluralization, abbreviation, and other language operations, to their root form. For example,
apples
will be turned toapple
,children
tochild
,turned
toturn
,am
,are
,is
will be turned tobe
.
Parameters
Limits
The maximum length accepted is 64k characters.
Parameter | Meaning | Example values |
---|---|---|
colormap | the color palette that will be used to create tha image | Greys , Purples , Blues , Greens , Oranges , Reds , YlOrBr , YlOrRd , OrRd , PuRd , RdPu , BuPu , GnBu , PuBu , YlGnBu , PuBuGn , BuGn , YlGn |
bg_color | backgroud color in hexadecimal (or by name) of the image | white , red , #32a852 , #d7e0da , etc. |
stop_words | a list of comma separatared words to discard from word cloud | textkit,word,something |
Invokation
- cURL
- Python
- PHP
curl -L -G 'https://api.textkit.ai/generate/wordcloud' \
--data-urlencode 'colormap=Blues' \
--header 'X-API-Key: your_api_key_here'
--data-raw 'This is a test of the TextKit wordcloud API endpoint'
# save its output to a file
import requests
url = "https://api.textkit.ai/generate/wordcloud?colormap=Blues"
payload="This is a test of the TextKit wordcloud API endpoint"
headers = {
'X-API-Key': 'your_api_key_here',
'Content-Type': 'text/plain'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text) # save this response as a file
<?php
$curl = curl_init();
$url = "https://api.textkit.ai/generate/wordcloud?colormap=" . urlencode("Blues");
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_POSTFIELDS =>'This is a test of the TextKit wordcloud API endpoint',
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-API-Key: your_api_key_here',
'Content-Type: text/plain'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response; // save this response as a file
Response
The API will return an SVG file that you will need to render in order to display it.
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">
<style>@font-face{font-family:'Droid Sans Mono';font-weight:normal;font-style:normal;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAdsAAsAAAAACKgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABeAAAAFYAAABgfZl2O2NtYXAAAAH0AAAAUAAAAGQBfQJWZ2FzcAAAB2AAAAAMAAAADAAEAAdnbHlmAAACaAAABBEAAATQywjVk2hlYWQAAAEIAAAANgAAADYEsT4SaGhlYQAAAUAAAAAgAAAAJAw9AuhobXR4AAAB0AAAACQAAAAkCWAF0mxvY2EAAAJEAAAAJAAAACQJ7wsebWF4cAAAAWAAAAAYAAAAIAAUACNuYW1lAAAGfAAAAMsAAAFoHBo1AHBvc3QAAAdIAAAAFgAAACD/aQBnAAEAAAABAAAqRmKfXw889QALCAAAAAAAwcfpVAAAAADe/QuY//z+FATRBhQAAAAJAAIAAAAAAAB4nGNgZGBgz/0ny8DAcvb/n/9/WC4yAEVQACMArNsHL3icY2BkYGAQZFBiYGIAAUYGNAAABZsAOHicY2BmOcs4gYGVgYN1FqsxAwOjHIRmvsCQxviJgYGJm42TmYOFiYmFASjJgAQMHYOdGRwYEhkq2OT/iTC0sOcyPlZgYJwPkmPxYt0GpBQYGABZMQy9AAAEzQDBAIcArACJAIUAxQDXALwAoABzAJ4BCADLAIsAoP/8AGB4nGNgYGBiYGBgBmIRIMkIplkYAoC0ABCCxBMZUhkyGXIYChhKGSr+/weLJANFshnyGIoYyv///7/g//z/c/7P/j/r/8z/M8BmoAAAI0oVxwAAAAAANABaAIsAtwDaAPsBEgEwAVkBigGoAdcB+gIZAkkCaHicRZR/SJx1HMe/n+d5fO5S0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7j9LSTfJZefjyqSnuzG6rm1FS6TzH17mnswUeQUVkPCQxffbnng3yoFt4+Ugx5+FPUPJPkHvuIUiSFKd2bF88xhqrw8+YZOp+bXn8PWxIrH3cn6Ew6hVmzDFMTC8KuvxNUvZGi6dyk6hyqFkWdPwy7i6YTsv/3LopFZ/bJezu+Xuyv9bjlPG9ksq3wSTlvR13vXaEKwjjGR2be/WJ+4jPhOfOb5MDDc0LeJp/VEL+B+Bl8FQZs5ZseiM3z9K+gz+NbcHGOkjE9LxiCG+vgvLlszsI4VvwD9PeDKwAAAHicfY5BDsFQFEUPiphYgIH8BSCKxFhIjExIDMyqpJpIK8WABViBTdiJBVmA2+9LjKS5zX3v3XfeB6qsKFHwasBO+vgCTVUfX6TOzfkSA+7Oez+ZMi2ezldo8GJCTCSdpCtbNhgpUB3IhaQcuJDZ1E5dw0Pq0dU3FM0wVSbVdK9tw1g+007+Dyw1JaGjO5lcbPkLTRKOcjM7TZlrN+IsRqDcSLNQnUTprWpDW/pPWNrk0d0z+LqZv9GwFjcWeWO7Pv0f0pfjKG8rUjU3AHicY2BmAIP/aQxpQIqRAQ0AACn+AdAAAAAAAAIABQAC//8AAw==")format("woff");}</style>
<style>text{font-family:'Droid Sans Mono';font-weight:normal;font-style:normal;}</style>
<text transform="translate(152,138)" font-size="92" style="fill:rgb(42, 122, 185)">test</text>
<text transform="translate(28,59)" font-size="76" style="fill:rgb(171, 208, 230)">textkit</text>
<text transform="translate(17,186)" font-size="62" style="fill:rgb(228, 239, 249)">wordcloud</text>
<text transform="translate(22,110)" font-size="62" style="fill:rgb(8, 77, 150)">api</text>
<text transform="translate(227,77)" font-size="22" style="fill:rgb(212, 228, 244)">endpoint</text>
</svg>
Which will turn into something like the following once rendered.