How to Get Nouns from a Text String using Java: NLP API

Cloudmersive
1 min readApr 12, 2022

Find nouns, segment nouns, return nouns: that’s the long and short of our Noun Segmentation API. Take advantage of this basic & useful NLP operation in just a few steps with ready-to-run code snippets provided from our API Console page below in Java.

To get started, install the Java SDK with Maven (for Gradle, review additional snippets available via the Cloudmersive API Console under the /nlp/get/words/nouns/string dropdown). Add a reference to the repository in pom.xml:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

Then add a reference to the dependency in pom.xml:

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>

Finally, you’re all set to go after you 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.wordsNouns(input);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling WordsApi#wordsNouns");
e.printStackTrace();
}

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.