Get Proper Nouns in a String using Java: NLP API

Cloudmersive
1 min readApr 11, 2022

--

For us humans, proper nouns are a fluid aspect of language that we subconsciously apply the correct amount of weight to, such as telling our friends we stayed at the “Hilton” or ate “Frosted Flakes” for breakfast. For a computer, proper nouns only represent another category of entities in a text string that require a reference database to appropriately identify and single out.

Thankfully, our NLP APIs can do that heavy lifting for you. Using our Proper Noun Segmentation API, you can identify and separate any proper nouns within an input text string. Take advantage of ready-to-run code provided in Java below to make a custom code connection.

Start by installing the Java SDK with Maven (instructions available for Gradle via our API platform). Add a reference to the repository in pom.xml:

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

Next add a reference to the dependency:

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

Last but not least, add the import classes and call the 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.wordsProperNouns(input);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling WordsApi#wordsProperNouns");
e.printStackTrace();
}

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet