Last active
August 15, 2018 19:01
-
-
Save brendandawes/7d9fc84d94c538d8a2355daaec961a44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http.requests.*; | |
void setup(){ | |
size(640,640); | |
String txt = "The Quick Brown Fox Jumped Over the Lazy Dog"; | |
JSONObject json = getJSONForText(txt); | |
PostRequest post = new PostRequest("https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-03-19"); | |
post.addUser(USERNAME,PASSWORD); | |
post.addHeader("Content-Type", "application/json"); | |
post.addJson(json.toString()); | |
post.send(); | |
println(post.getContent()); | |
} | |
void draw(){ | |
} | |
JSONObject getJSONForText(String txt){ | |
JSONObject json = new JSONObject(); | |
json.setString("text",txt); | |
JSONObject empty = new JSONObject(); | |
JSONObject features = new JSONObject(); | |
features.setJSONObject("sentiment",empty); | |
features.setJSONObject("keywords",empty); | |
features.setJSONObject("emotion",empty); | |
json.setJSONObject("features",features); | |
return json; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment