Get Verbs from an Input String: NLP API
1 min readApr 11, 2022
This iteration of our NLP API will return only the verbs from an input text string — perfect for use in conjunction with our other NLP segmentation APIs.
Using this API in Java (or any of 12 additional programming languages) is easy — just follow steps below to install the Java SDK with Maven and call the API function.
First add a reference to the repository in pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Next add one to the dependency:
<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>
Almost done — add the import classes and call the NLP function:
// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.WordsApi;ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");WordsApi apiInstance = new WordsApi();
String input = "input_example"; // String | Input string
try {
String result = apiInstance.wordsPost(input);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling WordsApi#wordsPost");
e.printStackTrace();
}
Easy as pie. Ensure your API key is included, and you’re all set to go.