SlideShare a Scribd company logo
1 of 50
Download to read offline
Natural Language Processing & It’s
Applications in AI
By : Prof. Ram Kumar Solanki
Asst. Professor – Computer Engineering
Contents
• What is NLP?
• History of NLP
• Advantages of NLP
• Disadvantages of NLP
• Components of NLP
• Applications of NLP
• How to build an NLP pipeline?
• Phases of NLP
• NLP Libraries
What is NLP?
• NLP stands for Natural Language
Processing, which is a part of Computer
Science, Human language, and Artificial
Intelligence.
• It is the technology that is used by
machines to understand, analyze,
manipulate, and interpret human's
languages.
What is NLP?
Look at the technologies around us:
• Spellcheck and autocorrect
• Auto-generated video captions
• Virtual assistants like Amazon’s Alexa
• Autocomplete
• Your news site’s suggested articles
What do they have in common?
What is NLP?
• All of these handy technologies exist
because of natural language processing!
Also known as NLP, the field is at the
intersection of linguistics, artificial
intelligence, and computer science.
• The goal? Enabling computers to interpret,
analyze, and approximate the generation
of human languages
History of NLP
• (1940-1960) - Focused on Machine Translation (MT)
– The Natural Languages Processing started in the year
1940s.
– 1948 - In the Year 1948, the first recognizable NLP
application was introduced in Birkbeck College, London.
– 1950s - In the Year 1950s, there was a conflicting view
between linguistics and computer science. Now,
Chomsky developed his first book syntactic structures
and claimed that language is generative in nature.
– In 1957, Chomsky also introduced the idea of Generative
Grammar, which is rule based descriptions of syntactic
structures.
History of NLP
• (1960-1980) - Flavored with Artificial
Intelligence (AI)
– In the year 1960 to 1980, the key
developments were:
– Augmented Transition Networks
(ATN)
• Augmented Transition Networks is a finite
state machine that is capable of recognizing
regular languages.
– Case Grammar
• Case Grammar was developed by Linguist
Charles J. Fillmore in the year 1968. Case
Grammar uses languages such as English to
express the relationship between nouns and
verbs by using the preposition.
History of NLP
• 1980 – Current
– Till the year 1980, natural language processing
systems were based on complex sets of hand-written
rules. After 1980, NLP introduced machine learning
algorithms for language processing.
– In the beginning of the year 1990s, NLP started
growing faster and achieved good process accuracy,
especially in English Grammar.
– In 1990 also, an electronic text introduced, which
provided a good resource for training and examining
natural language programs.
– Other factors may include the availability of computers
with fast CPUs and more memory.
– The major factor behind the advancement of natural
language processing was the Internet.
History of NLP
• Now, modern NLP consists of various
applications, like speech recognition,
machine translation, and machine
text reading.
• When we combine all these applications
then it allows the artificial intelligence to
gain knowledge of the world.
• Let's consider the example of AMAZON
ALEXA, using this robot you can ask the
question to Alexa, and it will reply to
you.
Advantages of NLP
• NLP helps users to ask questions about any subject and
get a direct response within seconds.
• NLP offers exact answers to the question means it does
not offer unnecessary and unwanted information.
• NLP helps computers to communicate with humans in
their languages.
• It is very time efficient.
• Most of the companies use NLP to improve the
efficiency of documentation processes, accuracy of
documentation, and identify the information from
large databases.
Disadvantages of NLP
• A list of disadvantages of NLP is given below:
– NLP may not show context.
– NLP is unpredictable
– NLP may require more keystrokes.
– NLP is unable to adapt to the new domain,
and it has a limited function that's why
NLP is built for a single and specific task
only.
Components of NLP
• There are the following two
components of NLP –
• 1. Natural Language Understanding (NLU)
• 2. Natural Language Generation (NLG)
Natural Language Understanding (NLU)
• Natural Language Understanding (NLU) helps the machine to
understand and analyze human language by extracting the
metadata from content such as concepts, entities, keywords,
emotion, relations, and semantic roles.
• NLU mainly used in Business applications to understand the
customer's problem in both spoken and written language.
• NLU involves the following tasks -
• It is used to map the given input into useful representation.
• It is used to analyze different aspects of the language.
Natural Language Generation (NLG)
• Natural Language Generation (NLG)
acts as a translator that converts the
computerized data into natural
language representation.
• It mainly involves Text planning,
Sentence planning, and Text
Realization.
Difference between NLU and NLG
NLU NLG
NLU is the process of reading and
interpreting language.
NLG is the process of writing or
generating language.
It produces non-linguistic
outputs from natural language
inputs.
It produces constructing natural
language outputs from non-
linguistic inputs.
Applications of NLP
• 1. Question Answering
– Question Answering focuses on building systems
that automatically answer the questions asked by
humans in a natural language.
Applications of NLP
• 2. Spam Detection
– Spam detection is used to detect
unwanted e-mails getting to a user's
inbox.
Applications of NLP
• 3. Sentiment Analysis
– Sentiment Analysis is also known as opinion mining. It is
used on the web to analyze the attitude, behavior, and
emotional state of the sender.
– This application is implemented through a combination
of NLP (Natural Language Processing) and statistics by
assigning the values to the text (positive, negative, or
natural), identify the mood of the context (happy, sad,
angry, etc.)
Applications of NLP
• 4. Machine Translation
– Machine translation is used to translate text or speech
from one natural language to another natural language.
Applications of NLP
• 5. Spelling correction
– Microsoft Corporation provides word
processor software like MS-word, PowerPoint
for the spelling correction.
Applications of NLP
• 6. Speech Recognition
– speech recognition is used for converting spoken
words into text.
– It is used in applications, such as mobile, home
automation, video recovery, dictating to Microsoft
Word, voice biometrics, voice user interface, and so
on.
Applications of NLP
• 7. Chatbot
– Implementing the Chatbot is one of the important
applications of NLP.
– It is used by many companies to provide the
customer's chat services.
Applications of NLP
• 8. Information extraction
– Information extraction is one of the
most important applications of NLP.
– It is used for extracting structured
information from unstructured or
semi-structured machine-readable
documents.
Applications of NLP
• 9. Natural Language Understanding
(NLU)
– It converts a large set of text into
more formal representations such as
first-order logic structures that are
easier for the computer programs to
manipulate notations of the natural
language processing.
How to build an NLP pipeline
• There are the following steps to build an NLP pipeline -
• Step1: Sentence Segmentation
• Step2: Word Tokenization
• Step3: Stemming
• Step 4: Lemmatization
• Step 5: Identifying Stop Words
• Step 6: Dependency Parsing
• Step 7: POS tags
• Step 8: Named Entity Recognition (NER)
• Step 9: Chunking
Step1: Sentence Segmentation
• Sentence Segment is the first step for building the NLP pipeline. It breaks
the paragraph into separate sentences.
• Example: Consider the following paragraph -
• Independence Day is one of the important festivals for every Indian
citizen. It is celebrated on the 15th of August each year ever since India
got independence from the British rule. The day celebrates independence
in the true sense.
• Sentence Segment produces the following result:
• "Independence Day is one of the important festivals for every Indian
citizen."
• "It is celebrated on the 15th of August each year ever since India got
independence from the British rule."
• "This day celebrates independence in the true sense."
Using NLTK
• import nltk
• text = "Independence Day is one of the important festivals for every Indian citizen. It
is celebrated on the 15th of August each year ever since India got independence
from the British rule. The day celebrates independence in the true sense."
• sentences = nltk.sent_tokenize(text) #whole paragraph break into sentence
• for sentence in sentences:
• print(sentence)
• print()
•
• Independence Day is one of the important festivals for every Indian citizen.
• It is celebrated on the 15th of August each year ever since India got independence
from the British rule.
• The day celebrates independence in the true sense.
Step2: Word Tokenization
• Word tokenization means separate the words from
sentence.
• Also called as word segmentation.
• Dividing the string of written language into its words.
• Use the nltk.word_tokenize function.
Using NLTK
• for sentence in sentences:
• word = nltk.word_tokenize(sentence)
• print(word)
• print()
Output:
• ['Independence', 'Day', 'is', 'one', 'of', 'the', 'important', 'festivals', 'for',
'every', 'Indian', 'citizen', '.']
• ['It', 'is', 'celebrated', 'on', 'the', '15th', 'of', 'August', 'each', 'year', 'ever',
'since', 'India', 'got', 'independence', 'from', 'the', 'British', 'rule', '.']
• ['The', 'day', 'celebrates', 'independence', 'in', 'the', 'true', 'sense', '.']
Step3: Stemming
• Stemming is used to normalize words into its base form or
root form.
• For example, celebrates, celebrated and celebrating, all these
words are originated with a single root word "celebrate."
• The big problem with stemming is that sometimes it
produces the root word which may not have any meaning.
• For Example, intelligence, intelligent, and intelligently, all
these words are originated with a single root word
"intelligen."
• In English, the word "intelligen" do not have any meaning.
Using NLTK
• In [13]: from nltk.stem.wordnet import
WordNetLemmatizer
• lemmaztization = WordNetLemmatizer()
• from nltk.stem.porter import PorterStemmer
• stemmer = PorterStemmer()
• word = "intelligent"
• lemmaztization.lemmatize(word,"v")
• Out[13]: 'intelligent'
• stemmer.stem(word)
• Out[14]: 'intellig'
Step 4: Lemmatization
• Lemmatization is quite similar to the
Stamming. It is used to group different
inflected forms of the word, called Lemma.
The main difference between Stemming and
lemmatization is that it produces the root
word, which has a meaning.
• For example: In lemmatization, the words
intelligence, intelligent, and intelligently has a
root word intelligent, which has a meaning.
Using NLTK
• from nltk.stem import PorterStemmer,WordNetLemmatizer
• from nltk.corpus import wordnet
• def compare_stemmer_and_lemmatizer(stemmer, lemmatizer, word, pos):
• print("stemmer:", stemmer.stem(word))
• print("Lemmatizer:", lemmatizer.lemmatize(word,pos))
• print()
• lemmatizer = WordNetLemmatizer()
• stemmer = PorterStemmer()
• compare_stemmer_and_lemmatizer(stemmer,lemmatizer, word = "seen",
pos=wordnet.VERB)
• stemmer: seen
• Lemmatizer: see
Step 5: Identifying Stop Words
• In English, there are a lot of words that
appear very frequently like "is", "and",
"the", and "a". NLP pipelines will flag
these words as stop words. Stop words
might be filtered out before doing any
statistical analysis.
• Example: He is a good boy.
Using NLTK
• from nltk.corpus import stopwords
• print(stopwords.words("english"))
• Output :
• ['i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', "you're", "you've",
"you'll", "you'd", 'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 'himself',
'she', "she's", 'her', 'hers', 'herself', 'it', "it's", 'its', 'itself', 'they', 'them', 'their',
'theirs', 'themselves', 'what', 'which', 'who', 'whom', 'this', 'that', "that'll", 'these',
'those', 'am', 'is', 'are', 'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having',
'do', 'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if', 'or', 'because', 'as', 'until',
'while', 'of', 'at', 'by', 'for', 'with', 'about', 'against', 'between', 'into', 'through',
'during', 'before', 'after', 'above', 'below', 'to', 'from', 'up', 'down', 'in', 'out', 'on', 'off',
'over', 'under', 'again', 'further', 'then', 'once', 'here', 'there', 'when', 'where', 'why',
'how', 'all', 'any', 'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no', 'nor',
'not', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 's', 't', 'can', 'will', 'just', 'don',
"don't", 'should', "should've", 'now', 'd', 'll', 'm', 'o', 're', 've', 'y', 'ain', 'aren', "aren't",
'couldn', "couldn't", 'didn', "didn't", 'doesn', "doesn't", 'hadn', "hadn't", 'hasn',
"hasn't", 'haven', "haven't", 'isn', "isn't", 'ma', 'mightn', "mightn't", 'mustn',
"mustn't", 'needn', "needn't", 'shan', "shan't", 'shouldn', "shouldn't", 'wasn',
"wasn't", 'weren', "weren't", 'won', "won't", 'wouldn', "wouldn't"]
Step 6: Dependency Parsing
• Dependency Parsing is used to find that
how all the words in the sentence are
related to each other.
Step 7: POS tags
• POS stands for parts of speech, which includes
Noun, verb, adverb, and Adjective. It indicates
that how a word functions with its meaning as
well as grammatically within the sentences. A
word has one or more parts of speech based on
the context in which it is used.
• Example: "Google" something on the Internet.
• In the above example, Google is used as a verb,
although it is a proper noun.
Using NLTK
• import nltk
• from nltk.corpus import stopwords
• from nltk.tokenize import
word_tokenize, sent_tokenize
• stop_words =
set(stopwords.words('english'))
Using NLTK
• text="Sukanya, Rajib and Naba are my good friends. Sukanya is getting married
next year. Marriage is a big step in one’s life.It is both exciting and frightening.
But friendship is a sacred bond between people.It is a special kind of love
between us. Many of you must have tried searching for a friend but never
found the right one.“
• tokenized = sent_tokenize(text)
• for i in tokenized:
• wordsList = nltk.word_tokenize(i)
• wordsList = [w for w in wordsList if not w in stop_words]
• tagged = nltk.pos_tag(wordsList)
• print(tagged)
Using NLTK
• Output :
• [('Sukanya', 'NNP'), (',', ','), ('Rajib', 'NNP'), ('Naba', 'NNP'),
('good', 'JJ'), ('friends', 'NNS'), ('.', '.')]
• [('Sukanya', 'NNP'), ('getting', 'VBG'), ('married', 'VBN'),
('next', 'JJ'), ('year', 'NN'), ('.', '.')]
• [('Marriage', 'NN'), ('big', 'JJ'), ('step', 'NN'), ('one', 'CD'), ('’',
'NN'), ('life.It', 'NN'), ('exciting', 'VBG'), ('frightening', 'NN'),
('.', '.')]
• [('But', 'CC'), ('friendship', 'NN'), ('sacred', 'VBD'), ('bond',
'NN'), ('people.It', 'NN'), ('special', 'JJ'), ('kind', 'NN'), ('love',
'VB'), ('us', 'PRP'), ('.', '.')]
• [('Many', 'JJ'), ('must', 'MD'), ('tried', 'VB'), ('searching', 'VBG'),
('friend', 'NN'), ('never', 'RB'), ('found', 'VBD'), ('right', 'JJ'),
('one', 'CD'), ('.', '.')]
Step 8: Named Entity Recognition (NER)
• Named Entity Recognition (NER) is the
process of detecting the named entity
such as person name, movie name,
organization name, or location.
Using NLTK
• In [53]: loc=[('TCS', 'IN', 'PUNE'),
• ('INFOCEPT', 'IN', 'PUNE'),
• ('WIPRO', 'IN', 'PUNE'),
• ('AMAZON', 'IN', 'HYDERABAD'),
• ('INTEL', 'IN', 'HYDERABAD'),
• ]
• query = [e1 for (e1, rel, e2) in loc if e2=='HYDERABAD']
• print(query)
• Output: ['AMAZON', 'INTEL']
Step 9: Chunking
• Chunking is used to collect the
individual piece of information and
grouping them into bigger pieces of
sentences.
Using NLTK
• sentence = [("the", "DT"), ("little", "JJ"), ("yellow", "JJ"),("dog", "NN"), ("barked",
"VBD"), ("at", "IN"), ("the", "DT"), ("cat", "NN")]
• grammar = "NP: {<DT>?<JJ>*<NN>}"
• cp = nltk.RegexpParser(grammar)
• result = cp.parse(sentence)
• print(result)
• (S
• (NP the/DT little/JJ yellow/JJ dog/NN)
• barked/VBD
• at/IN
• (NP the/DT cat/NN))
• result.draw()
Phases of NLP
• There are the following five phases of
NLP:
NLP Libraries
• Scikit-learn: It provides a wide range of
algorithms for building machine learning
models in Python.
• Natural language Toolkit (NLTK): NLTK is a
complete toolkit for all NLP techniques.
• Pattern: It is a web mining module for NLP and
machine learning.
• TextBlob: It provides an easy interface to learn
basic NLP tasks like sentiment analysis, noun
phrase extraction, or pos-tagging.
NLP Libraries
• Quepy: Quepy is used to transform natural
language questions into queries in a
database query language.
• SpaCy: SpaCy is an open-source NLP
library which is used for Data Extraction,
Data Analysis, Sentiment Analysis, and
Text Summarization.
• Gensim: Gensim works with large datasets
and processes data streams.
Natural language processing and its application in ai

More Related Content

What's hot

Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)VenkateshMurugadas
 
Natural Language Processing in AI
Natural Language Processing in AINatural Language Processing in AI
Natural Language Processing in AISaurav Shrestha
 
Natural Language Processing (NLP)
Natural Language Processing (NLP)Natural Language Processing (NLP)
Natural Language Processing (NLP)Yuriy Guts
 
Natural language processing
Natural language processingNatural language processing
Natural language processingAbash shah
 
Natural language processing
Natural language processingNatural language processing
Natural language processingYogendra Tamang
 
Natural language processing (NLP)
Natural language processing (NLP) Natural language processing (NLP)
Natural language processing (NLP) ASWINKP11
 
Natural language processing PPT presentation
Natural language processing PPT presentationNatural language processing PPT presentation
Natural language processing PPT presentationSai Mohith
 
Natural language processing
Natural language processingNatural language processing
Natural language processingprashantdahake
 
Natural language processing in artificial intelligence
Natural language processing in artificial intelligenceNatural language processing in artificial intelligence
Natural language processing in artificial intelligenceAbdul Rafay
 
Natural Language Processing
Natural Language Processing Natural Language Processing
Natural Language Processing Adarsh Saxena
 
Natural lanaguage processing
Natural lanaguage processingNatural lanaguage processing
Natural lanaguage processinggulshan kumar
 
Natural language processing
Natural language processing Natural language processing
Natural language processing Md.Sumon Sarder
 
Nlp presentation
Nlp presentationNlp presentation
Nlp presentationSurya Sg
 
Natural language processing
Natural language processingNatural language processing
Natural language processingHansi Thenuwara
 
Deep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
Deep Learning for NLP (without Magic) - Richard Socher and Christopher ManningDeep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
Deep Learning for NLP (without Magic) - Richard Socher and Christopher ManningBigDataCloud
 
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...Edureka!
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processingsaurabhnarhe
 

What's hot (20)

Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
Natural Language Processing in AI
Natural Language Processing in AINatural Language Processing in AI
Natural Language Processing in AI
 
Natural Language Processing (NLP)
Natural Language Processing (NLP)Natural Language Processing (NLP)
Natural Language Processing (NLP)
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
Natural language processing (NLP)
Natural language processing (NLP) Natural language processing (NLP)
Natural language processing (NLP)
 
Natural language processing PPT presentation
Natural language processing PPT presentationNatural language processing PPT presentation
Natural language processing PPT presentation
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
Natural language processing in artificial intelligence
Natural language processing in artificial intelligenceNatural language processing in artificial intelligence
Natural language processing in artificial intelligence
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
Natural Language Processing
Natural Language Processing Natural Language Processing
Natural Language Processing
 
Natural lanaguage processing
Natural lanaguage processingNatural lanaguage processing
Natural lanaguage processing
 
Natural language processing
Natural language processing Natural language processing
Natural language processing
 
Nlp presentation
Nlp presentationNlp presentation
Nlp presentation
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
Deep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
Deep Learning for NLP (without Magic) - Richard Socher and Christopher ManningDeep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
Deep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
 
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 

Similar to Natural language processing and its application in ai

Addis Ababa University.pptx
Addis Ababa University.pptxAddis Ababa University.pptx
Addis Ababa University.pptxBelay Alemayehu
 
Introduction to NLP_1.pptx
Introduction to NLP_1.pptxIntroduction to NLP_1.pptx
Introduction to NLP_1.pptxjkamble
 
Introduction to NLP.pptx
Introduction to NLP.pptxIntroduction to NLP.pptx
Introduction to NLP.pptxjkamble
 
Natural Language Processing for development
Natural Language Processing for developmentNatural Language Processing for development
Natural Language Processing for developmentAravind Reddy
 
Natural Language Processing for development
Natural Language Processing for developmentNatural Language Processing for development
Natural Language Processing for developmentAravind Reddy
 
NATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptxNATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptxsaivinay93
 
NATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptxNATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptxFitsum36
 
NLP-ppt.pptx nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
NLP-ppt.pptx nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnNLP-ppt.pptx nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
NLP-ppt.pptx nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnRAtna29
 
Natural Language Processing (NLP).pptx
Natural Language Processing (NLP).pptxNatural Language Processing (NLP).pptx
Natural Language Processing (NLP).pptxSHIBDASDUTTA
 
naturallanguageprocessing-160722053804 (1).pdf
naturallanguageprocessing-160722053804 (1).pdfnaturallanguageprocessing-160722053804 (1).pdf
naturallanguageprocessing-160722053804 (1).pdfRohanSharma573161
 
An Overview of Natural Language Processing.pptx
An Overview of Natural Language Processing.pptxAn Overview of Natural Language Processing.pptx
An Overview of Natural Language Processing.pptxSoftxai
 
naturallanguageprocessing-160722053804.pdf
naturallanguageprocessing-160722053804.pdfnaturallanguageprocessing-160722053804.pdf
naturallanguageprocessing-160722053804.pdfshakeelAsghar6
 
Untitled presentation.pdf
Untitled presentation.pdfUntitled presentation.pdf
Untitled presentation.pdfUpinder Kaur
 
NLP presentation.pptx
NLP presentation.pptxNLP presentation.pptx
NLP presentation.pptxpysgpa
 
NATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptxNATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptxMohdSohail65
 
Natural Language Processing-(NLP).pptx
Natural Language Processing-(NLP).pptxNatural Language Processing-(NLP).pptx
Natural Language Processing-(NLP).pptxSHIBDASDUTTA
 

Similar to Natural language processing and its application in ai (20)

Addis Ababa University.pptx
Addis Ababa University.pptxAddis Ababa University.pptx
Addis Ababa University.pptx
 
Unit 5f.pptx
Unit 5f.pptxUnit 5f.pptx
Unit 5f.pptx
 
Introduction to NLP_1.pptx
Introduction to NLP_1.pptxIntroduction to NLP_1.pptx
Introduction to NLP_1.pptx
 
Introduction to NLP.pptx
Introduction to NLP.pptxIntroduction to NLP.pptx
Introduction to NLP.pptx
 
Natural Language Processing for development
Natural Language Processing for developmentNatural Language Processing for development
Natural Language Processing for development
 
Natural Language Processing for development
Natural Language Processing for developmentNatural Language Processing for development
Natural Language Processing for development
 
NATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptxNATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptx
 
NATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptxNATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptx
 
1 Introduction.ppt
1 Introduction.ppt1 Introduction.ppt
1 Introduction.ppt
 
WomenTech_Event
WomenTech_EventWomenTech_Event
WomenTech_Event
 
NLP-ppt.pptx nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
NLP-ppt.pptx nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnNLP-ppt.pptx nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
NLP-ppt.pptx nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
 
Natural Language Processing (NLP).pptx
Natural Language Processing (NLP).pptxNatural Language Processing (NLP).pptx
Natural Language Processing (NLP).pptx
 
subrat
 subrat subrat
subrat
 
naturallanguageprocessing-160722053804 (1).pdf
naturallanguageprocessing-160722053804 (1).pdfnaturallanguageprocessing-160722053804 (1).pdf
naturallanguageprocessing-160722053804 (1).pdf
 
An Overview of Natural Language Processing.pptx
An Overview of Natural Language Processing.pptxAn Overview of Natural Language Processing.pptx
An Overview of Natural Language Processing.pptx
 
naturallanguageprocessing-160722053804.pdf
naturallanguageprocessing-160722053804.pdfnaturallanguageprocessing-160722053804.pdf
naturallanguageprocessing-160722053804.pdf
 
Untitled presentation.pdf
Untitled presentation.pdfUntitled presentation.pdf
Untitled presentation.pdf
 
NLP presentation.pptx
NLP presentation.pptxNLP presentation.pptx
NLP presentation.pptx
 
NATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptxNATURAL LANGUAGE PROCESSING.pptx
NATURAL LANGUAGE PROCESSING.pptx
 
Natural Language Processing-(NLP).pptx
Natural Language Processing-(NLP).pptxNatural Language Processing-(NLP).pptx
Natural Language Processing-(NLP).pptx
 

Recently uploaded

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 

Recently uploaded (20)

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 

Natural language processing and its application in ai

  • 1. Natural Language Processing & It’s Applications in AI By : Prof. Ram Kumar Solanki Asst. Professor – Computer Engineering
  • 2. Contents • What is NLP? • History of NLP • Advantages of NLP • Disadvantages of NLP • Components of NLP • Applications of NLP • How to build an NLP pipeline? • Phases of NLP • NLP Libraries
  • 3.
  • 4. What is NLP? • NLP stands for Natural Language Processing, which is a part of Computer Science, Human language, and Artificial Intelligence. • It is the technology that is used by machines to understand, analyze, manipulate, and interpret human's languages.
  • 5. What is NLP? Look at the technologies around us: • Spellcheck and autocorrect • Auto-generated video captions • Virtual assistants like Amazon’s Alexa • Autocomplete • Your news site’s suggested articles What do they have in common?
  • 6. What is NLP? • All of these handy technologies exist because of natural language processing! Also known as NLP, the field is at the intersection of linguistics, artificial intelligence, and computer science. • The goal? Enabling computers to interpret, analyze, and approximate the generation of human languages
  • 7. History of NLP • (1940-1960) - Focused on Machine Translation (MT) – The Natural Languages Processing started in the year 1940s. – 1948 - In the Year 1948, the first recognizable NLP application was introduced in Birkbeck College, London. – 1950s - In the Year 1950s, there was a conflicting view between linguistics and computer science. Now, Chomsky developed his first book syntactic structures and claimed that language is generative in nature. – In 1957, Chomsky also introduced the idea of Generative Grammar, which is rule based descriptions of syntactic structures.
  • 8. History of NLP • (1960-1980) - Flavored with Artificial Intelligence (AI) – In the year 1960 to 1980, the key developments were: – Augmented Transition Networks (ATN) • Augmented Transition Networks is a finite state machine that is capable of recognizing regular languages. – Case Grammar • Case Grammar was developed by Linguist Charles J. Fillmore in the year 1968. Case Grammar uses languages such as English to express the relationship between nouns and verbs by using the preposition.
  • 9. History of NLP • 1980 – Current – Till the year 1980, natural language processing systems were based on complex sets of hand-written rules. After 1980, NLP introduced machine learning algorithms for language processing. – In the beginning of the year 1990s, NLP started growing faster and achieved good process accuracy, especially in English Grammar. – In 1990 also, an electronic text introduced, which provided a good resource for training and examining natural language programs. – Other factors may include the availability of computers with fast CPUs and more memory. – The major factor behind the advancement of natural language processing was the Internet.
  • 10. History of NLP • Now, modern NLP consists of various applications, like speech recognition, machine translation, and machine text reading. • When we combine all these applications then it allows the artificial intelligence to gain knowledge of the world. • Let's consider the example of AMAZON ALEXA, using this robot you can ask the question to Alexa, and it will reply to you.
  • 11. Advantages of NLP • NLP helps users to ask questions about any subject and get a direct response within seconds. • NLP offers exact answers to the question means it does not offer unnecessary and unwanted information. • NLP helps computers to communicate with humans in their languages. • It is very time efficient. • Most of the companies use NLP to improve the efficiency of documentation processes, accuracy of documentation, and identify the information from large databases.
  • 12. Disadvantages of NLP • A list of disadvantages of NLP is given below: – NLP may not show context. – NLP is unpredictable – NLP may require more keystrokes. – NLP is unable to adapt to the new domain, and it has a limited function that's why NLP is built for a single and specific task only.
  • 13. Components of NLP • There are the following two components of NLP – • 1. Natural Language Understanding (NLU) • 2. Natural Language Generation (NLG)
  • 14. Natural Language Understanding (NLU) • Natural Language Understanding (NLU) helps the machine to understand and analyze human language by extracting the metadata from content such as concepts, entities, keywords, emotion, relations, and semantic roles. • NLU mainly used in Business applications to understand the customer's problem in both spoken and written language. • NLU involves the following tasks - • It is used to map the given input into useful representation. • It is used to analyze different aspects of the language.
  • 15. Natural Language Generation (NLG) • Natural Language Generation (NLG) acts as a translator that converts the computerized data into natural language representation. • It mainly involves Text planning, Sentence planning, and Text Realization.
  • 16. Difference between NLU and NLG NLU NLG NLU is the process of reading and interpreting language. NLG is the process of writing or generating language. It produces non-linguistic outputs from natural language inputs. It produces constructing natural language outputs from non- linguistic inputs.
  • 17. Applications of NLP • 1. Question Answering – Question Answering focuses on building systems that automatically answer the questions asked by humans in a natural language.
  • 18. Applications of NLP • 2. Spam Detection – Spam detection is used to detect unwanted e-mails getting to a user's inbox.
  • 19. Applications of NLP • 3. Sentiment Analysis – Sentiment Analysis is also known as opinion mining. It is used on the web to analyze the attitude, behavior, and emotional state of the sender. – This application is implemented through a combination of NLP (Natural Language Processing) and statistics by assigning the values to the text (positive, negative, or natural), identify the mood of the context (happy, sad, angry, etc.)
  • 20. Applications of NLP • 4. Machine Translation – Machine translation is used to translate text or speech from one natural language to another natural language.
  • 21. Applications of NLP • 5. Spelling correction – Microsoft Corporation provides word processor software like MS-word, PowerPoint for the spelling correction.
  • 22. Applications of NLP • 6. Speech Recognition – speech recognition is used for converting spoken words into text. – It is used in applications, such as mobile, home automation, video recovery, dictating to Microsoft Word, voice biometrics, voice user interface, and so on.
  • 23. Applications of NLP • 7. Chatbot – Implementing the Chatbot is one of the important applications of NLP. – It is used by many companies to provide the customer's chat services.
  • 24. Applications of NLP • 8. Information extraction – Information extraction is one of the most important applications of NLP. – It is used for extracting structured information from unstructured or semi-structured machine-readable documents.
  • 25. Applications of NLP • 9. Natural Language Understanding (NLU) – It converts a large set of text into more formal representations such as first-order logic structures that are easier for the computer programs to manipulate notations of the natural language processing.
  • 26. How to build an NLP pipeline • There are the following steps to build an NLP pipeline - • Step1: Sentence Segmentation • Step2: Word Tokenization • Step3: Stemming • Step 4: Lemmatization • Step 5: Identifying Stop Words • Step 6: Dependency Parsing • Step 7: POS tags • Step 8: Named Entity Recognition (NER) • Step 9: Chunking
  • 27. Step1: Sentence Segmentation • Sentence Segment is the first step for building the NLP pipeline. It breaks the paragraph into separate sentences. • Example: Consider the following paragraph - • Independence Day is one of the important festivals for every Indian citizen. It is celebrated on the 15th of August each year ever since India got independence from the British rule. The day celebrates independence in the true sense. • Sentence Segment produces the following result: • "Independence Day is one of the important festivals for every Indian citizen." • "It is celebrated on the 15th of August each year ever since India got independence from the British rule." • "This day celebrates independence in the true sense."
  • 28. Using NLTK • import nltk • text = "Independence Day is one of the important festivals for every Indian citizen. It is celebrated on the 15th of August each year ever since India got independence from the British rule. The day celebrates independence in the true sense." • sentences = nltk.sent_tokenize(text) #whole paragraph break into sentence • for sentence in sentences: • print(sentence) • print() • • Independence Day is one of the important festivals for every Indian citizen. • It is celebrated on the 15th of August each year ever since India got independence from the British rule. • The day celebrates independence in the true sense.
  • 29. Step2: Word Tokenization • Word tokenization means separate the words from sentence. • Also called as word segmentation. • Dividing the string of written language into its words. • Use the nltk.word_tokenize function.
  • 30. Using NLTK • for sentence in sentences: • word = nltk.word_tokenize(sentence) • print(word) • print() Output: • ['Independence', 'Day', 'is', 'one', 'of', 'the', 'important', 'festivals', 'for', 'every', 'Indian', 'citizen', '.'] • ['It', 'is', 'celebrated', 'on', 'the', '15th', 'of', 'August', 'each', 'year', 'ever', 'since', 'India', 'got', 'independence', 'from', 'the', 'British', 'rule', '.'] • ['The', 'day', 'celebrates', 'independence', 'in', 'the', 'true', 'sense', '.']
  • 31. Step3: Stemming • Stemming is used to normalize words into its base form or root form. • For example, celebrates, celebrated and celebrating, all these words are originated with a single root word "celebrate." • The big problem with stemming is that sometimes it produces the root word which may not have any meaning. • For Example, intelligence, intelligent, and intelligently, all these words are originated with a single root word "intelligen." • In English, the word "intelligen" do not have any meaning.
  • 32. Using NLTK • In [13]: from nltk.stem.wordnet import WordNetLemmatizer • lemmaztization = WordNetLemmatizer() • from nltk.stem.porter import PorterStemmer • stemmer = PorterStemmer() • word = "intelligent" • lemmaztization.lemmatize(word,"v") • Out[13]: 'intelligent' • stemmer.stem(word) • Out[14]: 'intellig'
  • 33. Step 4: Lemmatization • Lemmatization is quite similar to the Stamming. It is used to group different inflected forms of the word, called Lemma. The main difference between Stemming and lemmatization is that it produces the root word, which has a meaning. • For example: In lemmatization, the words intelligence, intelligent, and intelligently has a root word intelligent, which has a meaning.
  • 34. Using NLTK • from nltk.stem import PorterStemmer,WordNetLemmatizer • from nltk.corpus import wordnet • def compare_stemmer_and_lemmatizer(stemmer, lemmatizer, word, pos): • print("stemmer:", stemmer.stem(word)) • print("Lemmatizer:", lemmatizer.lemmatize(word,pos)) • print() • lemmatizer = WordNetLemmatizer() • stemmer = PorterStemmer() • compare_stemmer_and_lemmatizer(stemmer,lemmatizer, word = "seen", pos=wordnet.VERB) • stemmer: seen • Lemmatizer: see
  • 35. Step 5: Identifying Stop Words • In English, there are a lot of words that appear very frequently like "is", "and", "the", and "a". NLP pipelines will flag these words as stop words. Stop words might be filtered out before doing any statistical analysis. • Example: He is a good boy.
  • 36. Using NLTK • from nltk.corpus import stopwords • print(stopwords.words("english")) • Output : • ['i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', "you're", "you've", "you'll", "you'd", 'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 'himself', 'she', "she's", 'her', 'hers', 'herself', 'it', "it's", 'its', 'itself', 'they', 'them', 'their', 'theirs', 'themselves', 'what', 'which', 'who', 'whom', 'this', 'that', "that'll", 'these', 'those', 'am', 'is', 'are', 'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having', 'do', 'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if', 'or', 'because', 'as', 'until', 'while', 'of', 'at', 'by', 'for', 'with', 'about', 'against', 'between', 'into', 'through', 'during', 'before', 'after', 'above', 'below', 'to', 'from', 'up', 'down', 'in', 'out', 'on', 'off', 'over', 'under', 'again', 'further', 'then', 'once', 'here', 'there', 'when', 'where', 'why', 'how', 'all', 'any', 'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no', 'nor', 'not', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 's', 't', 'can', 'will', 'just', 'don', "don't", 'should', "should've", 'now', 'd', 'll', 'm', 'o', 're', 've', 'y', 'ain', 'aren', "aren't", 'couldn', "couldn't", 'didn', "didn't", 'doesn', "doesn't", 'hadn', "hadn't", 'hasn', "hasn't", 'haven', "haven't", 'isn', "isn't", 'ma', 'mightn', "mightn't", 'mustn', "mustn't", 'needn', "needn't", 'shan', "shan't", 'shouldn', "shouldn't", 'wasn', "wasn't", 'weren', "weren't", 'won', "won't", 'wouldn', "wouldn't"]
  • 37. Step 6: Dependency Parsing • Dependency Parsing is used to find that how all the words in the sentence are related to each other.
  • 38. Step 7: POS tags • POS stands for parts of speech, which includes Noun, verb, adverb, and Adjective. It indicates that how a word functions with its meaning as well as grammatically within the sentences. A word has one or more parts of speech based on the context in which it is used. • Example: "Google" something on the Internet. • In the above example, Google is used as a verb, although it is a proper noun.
  • 39. Using NLTK • import nltk • from nltk.corpus import stopwords • from nltk.tokenize import word_tokenize, sent_tokenize • stop_words = set(stopwords.words('english'))
  • 40. Using NLTK • text="Sukanya, Rajib and Naba are my good friends. Sukanya is getting married next year. Marriage is a big step in one’s life.It is both exciting and frightening. But friendship is a sacred bond between people.It is a special kind of love between us. Many of you must have tried searching for a friend but never found the right one.“ • tokenized = sent_tokenize(text) • for i in tokenized: • wordsList = nltk.word_tokenize(i) • wordsList = [w for w in wordsList if not w in stop_words] • tagged = nltk.pos_tag(wordsList) • print(tagged)
  • 41. Using NLTK • Output : • [('Sukanya', 'NNP'), (',', ','), ('Rajib', 'NNP'), ('Naba', 'NNP'), ('good', 'JJ'), ('friends', 'NNS'), ('.', '.')] • [('Sukanya', 'NNP'), ('getting', 'VBG'), ('married', 'VBN'), ('next', 'JJ'), ('year', 'NN'), ('.', '.')] • [('Marriage', 'NN'), ('big', 'JJ'), ('step', 'NN'), ('one', 'CD'), ('’', 'NN'), ('life.It', 'NN'), ('exciting', 'VBG'), ('frightening', 'NN'), ('.', '.')] • [('But', 'CC'), ('friendship', 'NN'), ('sacred', 'VBD'), ('bond', 'NN'), ('people.It', 'NN'), ('special', 'JJ'), ('kind', 'NN'), ('love', 'VB'), ('us', 'PRP'), ('.', '.')] • [('Many', 'JJ'), ('must', 'MD'), ('tried', 'VB'), ('searching', 'VBG'), ('friend', 'NN'), ('never', 'RB'), ('found', 'VBD'), ('right', 'JJ'), ('one', 'CD'), ('.', '.')]
  • 42. Step 8: Named Entity Recognition (NER) • Named Entity Recognition (NER) is the process of detecting the named entity such as person name, movie name, organization name, or location.
  • 43. Using NLTK • In [53]: loc=[('TCS', 'IN', 'PUNE'), • ('INFOCEPT', 'IN', 'PUNE'), • ('WIPRO', 'IN', 'PUNE'), • ('AMAZON', 'IN', 'HYDERABAD'), • ('INTEL', 'IN', 'HYDERABAD'), • ] • query = [e1 for (e1, rel, e2) in loc if e2=='HYDERABAD'] • print(query) • Output: ['AMAZON', 'INTEL']
  • 44. Step 9: Chunking • Chunking is used to collect the individual piece of information and grouping them into bigger pieces of sentences.
  • 45. Using NLTK • sentence = [("the", "DT"), ("little", "JJ"), ("yellow", "JJ"),("dog", "NN"), ("barked", "VBD"), ("at", "IN"), ("the", "DT"), ("cat", "NN")] • grammar = "NP: {<DT>?<JJ>*<NN>}" • cp = nltk.RegexpParser(grammar) • result = cp.parse(sentence) • print(result) • (S • (NP the/DT little/JJ yellow/JJ dog/NN) • barked/VBD • at/IN • (NP the/DT cat/NN)) • result.draw()
  • 46.
  • 47. Phases of NLP • There are the following five phases of NLP:
  • 48. NLP Libraries • Scikit-learn: It provides a wide range of algorithms for building machine learning models in Python. • Natural language Toolkit (NLTK): NLTK is a complete toolkit for all NLP techniques. • Pattern: It is a web mining module for NLP and machine learning. • TextBlob: It provides an easy interface to learn basic NLP tasks like sentiment analysis, noun phrase extraction, or pos-tagging.
  • 49. NLP Libraries • Quepy: Quepy is used to transform natural language questions into queries in a database query language. • SpaCy: SpaCy is an open-source NLP library which is used for Data Extraction, Data Analysis, Sentiment Analysis, and Text Summarization. • Gensim: Gensim works with large datasets and processes data streams.