How to perform Named Entity Recognition NER in Python with NLP
Named Entity Recognition (or NER) uses the ever-growing power of Natural Language Processing (NLP) to extract a list of named entities from a string, such as people, places, and organizations. This has all kinds of great applications, but how can we get this functionality into your project without wrecking your weekend plans to do it?
Now our first step is to simply install our client library, which will require this pip install command.
pip install git+https://github.com/Cloudmersive/Cloudmersive.APIClient.Python.NLP.git
And now we are going to call the function titled extract_entities_string_post, which will process our input string and perform our NER.
from __future__ import print_functionimport timeimport cloudmersive_nlp_api_clientfrom cloudmersive_nlp_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_nlp_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_nlp_api_client.ExtractEntitiesStringApi(cloudmersive_nlp_api_client.ApiClient(configuration))value = 'value_example' # str | Input stringtry:# Extract entities from stringapi_response = api_instance.extract_entities_string_post(value)pprint(api_response)except ApiException as e:print("Exception when calling ExtractEntitiesStringApi->extract_entities_string_post: %s\n" % e)
Already finished! Super easy.