Last active
December 16, 2015 11:58
-
-
Save horte/5430710 to your computer and use it in GitHub Desktop.
Saplo Keyword Extraction
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 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... | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If using any other language, please follow http://developer.saplo.com/method/text-tags but with method name 'text.keywords' and the params above.