Skip to content

Instantly share code, notes, and snippets.

@horte
Last active December 16, 2015 11:58
Show Gist options
  • Save horte/5430710 to your computer and use it in GitHub Desktop.
Save horte/5430710 to your computer and use it in GitHub Desktop.
Saplo Keyword Extraction
//Import saplo4j: https://github.com/saplo/saplo4j
SaploClient client = new SaploClient.Builder("apikey",
"secretkey").endpoint("https://api.saplo.com/rpc/json").build();
JSONObject params = new JSONObject();
params.put("html", "<html><h1>Headline</h1><p>text</p></html>"); //will clean html and extract article text. Important to leave html structure since it is used when we are trying to extract the relevant article text.
//params.put("url", "http://saplo.com"); will fetch html and clean and extract article text
//params.put("text", "Cleaned text"); No article extraction will be done. Only using the text sent in.
/*
Note: Should only use one of the above params. Otherwise they are prioritized and used as below:
1. text
2. html
3. url
*/
JSONRPCRequestObject request = new JSONRPCRequestObject(0, "text.keywords", params);
try {
JSONRPCResponseObject response = client.sendAndReceive(request);
JSONObject result = (JSONObject) client.parseResponse(response);
} catch (SaploClientException e) {
// Some error occurred. Check error code and handle it...
}
@horte
Copy link
Author

horte commented Apr 21, 2013

If using any other language, please follow http://developer.saplo.com/method/text-tags but with method name 'text.keywords' and the params above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment