What is Natural entitiy recognition?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

What is Natural entitiy recognition?

What is Natural entitiy recognition?

This recipe explains what is Natural entitiy recognition

0

Recipe Objective

What is Natural entitiy recognition?

Natural entity recognition (NER) is an keyword extraction technique that uses Natural language processing to automatically identify named entities from a chunk of text or larger text and classify them according to the predetermined categories for e.g People, organization, email address, location, values etc. lets understand this with an example:

Jon is from canada he works at Apple.

So in the above the highlighted words are from some categories which are as follows:

Name - Jon

location - canada

Organization - Apple.

Some of the practical applications of NER are:

Scanning news articles for the people, organizations and locations reported.

Quickly retrieving geographical locations talked about in Twitter posts.

In Human Resources it will speed up the hiring process by summarizing applicants’ CVs; improve internal workflows by categorizing employee complaints and questions

In Customer Supprt it will improve response times by categorizing user requests, complaints and questions and filtering by priority keywords. And Many more..

Step 1 - Import the necessary libraries

import nltk from nltk.tokenize import word_tokenize from nltk.tag import pos_tag

Step 2 - Take a sample text

My_text = '''Thomas Alva Edison (February 11, 1847 – October 18, 1931) was an American inventor and businessman who has been described as America's greatest inventor.[1][2][3] He developed many devices in fields such as electric power generation, mass communication, sound recording, and motion pictures.[4] These inventions, which include the phonograph, the motion picture camera, and early versions of the electric light bulb, have had a widespread imp

We have taken a sample paragraph of Thomas Elva Edison from wikipedia for our reference

Step 3 - Tokenize the sentence in words by using word_tokenizer

tokenized_text = nltk.word_tokenize(My_text) print(tokenized_text)
['Thomas', 'Alva', 'Edison', '(', 'February', '11', ',', '1847', '–', 'October', '18', ',', '1931', ')', 'was', 'an', 'American', 'inventor', 'and', 'businessman', 'who', 'has', 'been', 'described', 'as', 'America', "'s", 'greatest', 'inventor', '.', '[', '1', ']', '[', '2', ']', '[', '3', ']', 'He', 'developed', 'many', 'devices', 'in', 'fields', 'such', 'as', 'electric', 'power', 'generation', ',', 'mass', 'communication', ',', 'sound', 'recording', ',', 'and', 'motion', 'pictures', '.', '[', '4', ']', 'These', 'inventions', ',', 'which', 'include', 'the', 'phonograph', ',', 'the', 'motion', 'picture', 'camera', ',', 'and', 'early', 'versions', 'of', 'the', 'electric', 'light', 'bulb', ',', 'have', 'had', 'a', 'widespread', 'impact', 'on', 'the', 'modern', 'industrialized', 'world', '.', '[', '5', ']', 'He', 'was', 'one', 'of', 'the', 'first', 'inventors', 'to', 'a', 'pply', 'the', 'principles', 'of', 'organized', 'science', 'and', 'teamwork', 'to', 'the', 'process', 'of', 'invention', ',', 'working', 'with', 'many', 'researchers', 'and', 'employees', '.', 'He', 'established', 'the', 'first', 'industrial', 'research', 'laboratory', '.', '[', '6', ']']

From the above we can see that the sentence has been tokenized into words

Step 4 - Apply part-of-speech (POS) tagging to the tokenized text

tagged_text = nltk.pos_tag(tokenized_text) print(tagged_text)
[('Thomas', 'NNP'), ('Alva', 'NNP'), ('Edison', 'NNP'), ('(', '('), ('February', 'NNP'), ('11', 'CD'), (',', ','), ('1847', 'CD'), ('–', 'NNP'), ('October', 'NNP'), ('18', 'CD'), (',', ','), ('1931', 'CD'), (')', ')'), ('was', 'VBD'), ('an', 'DT'), ('American', 'JJ'), ('inventor', 'NN'), ('and', 'CC'), ('businessman', 'NN'), ('who', 'WP'), ('has', 'VBZ'), ('been', 'VBN'), ('described', 'VBN'), ('as', 'IN'), ('America', 'NNP'), ("'s", 'POS'), ('greatest', 'JJS'), ('inventor', 'NN'), ('.', '.'), ('[', 'CC'), ('1', 'CD'), (']', 'JJ'), ('[', '$'), ('2', 'CD'), (']', 'NNP'), ('[', 'VBD'), ('3', 'CD'), (']', 'NN'), ('He', 'PRP'), ('developed', 'VBD'), ('many', 'JJ'), ('devices', 'NNS'), ('in', 'IN'), ('fields', 'NNS'), ('such', 'JJ'), ('as', 'IN'), ('electric', 'JJ'), ('power', 'NN'), ('generation', 'NN'), (',', ','), ('mass', 'NN'), ('communication', 'NN'), (',', ','), ('sound', 'NN'), ('recording', 'NN'), (',', ','), ('and', 'CC'), ('motion', 'NN'), ('pictures', 'NNS'), ('.', '.'), ('[', '$'), ('4', 'CD'), (']', 'NNP'), ('These', 'DT'), ('inventions', 'NNS'), (',', ','), ('which', 'WDT'), ('include', 'VBP'), ('the', 'DT'), ('phonograph', 'NN'), (',', ','), ('the', 'DT'), ('motion', 'NN'), ('picture', 'NN'), ('camera', 'NN'), (',', ','), ('and', 'CC'), ('early', 'JJ'), ('versions', 'NNS'), ('of', 'IN'), ('the', 'DT'), ('electric', 'JJ'), ('light', 'NN'), ('bulb', 'NN'), (',', ','), ('have', 'VBP'), ('had', 'VBN'), ('a', 'DT'), ('widespread', 'JJ'), ('impact', 'NN'), ('on', 'IN'), ('the', 'DT'), ('modern', 'JJ'), ('industrialized', 'VBN'), ('world', 'NN'), ('.', '.'), ('[', 'CC'), ('5', 'CD'), (']', 'NN'), ('He', 'PRP'), ('was', 'VBD'), ('one', 'CD'), ('of', 'IN'), ('the', 'DT'), ('first', 'JJ'), ('inventors', 'NNS'), ('to', 'TO'), ('a', 'DT'), ('pply', 'NN'), ('the', 'DT'), ('principles', 'NNS'), ('of', 'IN'), ('organized', 'VBN'), ('science', 'NN'), ('and', 'CC'), ('teamwork', 'NN'), ('to', 'TO'), ('the', 'DT'), ('process', 'NN'), ('of', 'IN'), ('invention', 'NN'), (',', ','), ('working', 'VBG'), ('with', 'IN'), ('many', 'JJ'), ('researchers', 'NNS'), ('and', 'CC'), ('employees', 'NNS'), ('.', '.'), ('He', 'PRP'), ('established', 'VBD'), ('the', 'DT'), ('first', 'JJ'), ('industrial', 'JJ'), ('research', 'NN'), ('laboratory', 'NN'), ('.', '.'), ('[', 'CC'), ('6', 'CD'), (']', 'NN')]

Step 5 - Pass the tagged text to a entity chunk function

print(nltk.ne_chunk(tagged_text))
(S
  (PERSON Thomas/NNP)
  (ORGANIZATION Alva/NNP Edison/NNP)
  (/(
  February/NNP
  11/CD
  ,/,
  1847/CD
  –/NNP
  October/NNP
  18/CD
  ,/,
  1931/CD
  )/)
  was/VBD
  an/DT
  (GPE American/JJ)
  inventor/NN
  and/CC
  businessman/NN
  who/WP
  has/VBZ
  been/VBN
  described/VBN
  as/IN
  (GPE America/NNP)
  's/POS
  greatest/JJS
  inventor/NN
  ./.
  [/CC
  1/CD
  ]/JJ
  [/$
  2/CD
  ]/NNP
  [/VBD
  3/CD
  ]/NN
  He/PRP
  developed/VBD
  many/JJ
  devices/NNS
  in/IN
  fields/NNS
  such/JJ
  as/IN
  electric/JJ
  power/NN
  generation/NN
  ,/,
  mass/NN
  communication/NN
  ,/,
  sound/NN
  recording/NN
  ,/,
  and/CC
  motion/NN
  pictures/NNS
  ./.
  [/$
  4/CD
  ]/NNP
  These/DT
  inventions/NNS
  ,/,
  which/WDT
  include/VBP
  the/DT
  phonograph/NN
  ,/,
  the/DT
  motion/NN
  picture/NN
  camera/NN
  ,/,
  and/CC
  early/JJ
  versions/NNS
  of/IN
  the/DT
  electric/JJ
  light/NN
  bulb/NN
  ,/,
  have/VBP
  had/VBN
  a/DT
  widespread/JJ
  impact/NN
  on/IN
  the/DT
  modern/JJ
  industrialized/VBN
  world/NN
  ./.
  [/CC
  5/CD
  ]/NN
  He/PRP
  was/VBD
  one/CD
  of/IN
  the/DT
  first/JJ
  inventors/NNS
  to/TO
  a/DT
  pply/NN
  the/DT
  principles/NNS
  of/IN
  organized/VBN
  science/NN
  and/CC
  teamwork/NN
  to/TO
  the/DT
  process/NN
  of/IN
  invention/NN
  ,/,
  working/VBG
  with/IN
  many/JJ
  researchers/NNS
  and/CC
  employees/NNS
  ./.
  He/PRP
  established/VBD
  the/DT
  first/JJ
  industrial/JJ
  research/NN
  laboratory/NN
  ./.
  [/CC
  6/CD
  ]/NN)

So here we have passed the tagged text to a entity chunk function (named entity chunk) which will return the text as a tree

Relevant Projects

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.