SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

natural language processing help at myassignmenthelp.net
natural language processing  help at myassignmenthelp.netnatural language processing  help at myassignmenthelp.net
natural language processing help at myassignmenthelp.netwww.myassignmenthelp.net
 
Natural language processing (nlp)
Natural language processing (nlp)Natural language processing (nlp)
Natural language processing (nlp)Kuppusamy P
 
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
Natural language processingNatural language processing
Natural language processingAbash shah
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processingsaurabhnarhe
 
Text clustering
Text clusteringText clustering
Text clusteringKU Leuven
 
Natural language processing (NLP)
Natural language processing (NLP) Natural language processing (NLP)
Natural language processing (NLP) ASWINKP11
 
Introduction to natural language processing
Introduction to natural language processingIntroduction to natural language processing
Introduction to natural language processingMinh Pham
 
Natural language processing
Natural language processingNatural language processing
Natural language processingprashantdahake
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language ProcessingMariana Soffer
 
Natural language processing
Natural language processingNatural language processing
Natural language processingYogendra Tamang
 
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 ProcessingNatural Language Processing
Natural Language ProcessingVeenaSKumar2
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language ProcessingBhavya Chawla
 

Was ist angesagt? (20)

natural language processing help at myassignmenthelp.net
natural language processing  help at myassignmenthelp.netnatural language processing  help at myassignmenthelp.net
natural language processing help at myassignmenthelp.net
 
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)
 
Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)Introduction to Natural Language Processing (NLP)
Introduction to Natural Language Processing (NLP)
 
NLP
NLPNLP
NLP
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
Text clustering
Text clusteringText clustering
Text clustering
 
NLP
NLPNLP
NLP
 
Natural language processing (NLP)
Natural language processing (NLP) Natural language processing (NLP)
Natural language processing (NLP)
 
Introduction to natural language processing
Introduction to natural language processingIntroduction to natural language processing
Introduction to natural language processing
 
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
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
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 ProcessingNatural Language Processing
Natural Language Processing
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 

Ähnlich wie 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
 
Introduction to Natural Language Processing
Introduction to Natural Language ProcessingIntroduction to Natural Language Processing
Introduction to Natural Language ProcessingMercy Rani
 
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
 
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
 
Natural language processing
Natural language processingNatural language processing
Natural language processingHansi Thenuwara
 
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
 

Ähnlich wie 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
 
Introduction to Natural Language Processing
Introduction to Natural Language ProcessingIntroduction to Natural Language Processing
Introduction to Natural Language Processing
 
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
 
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
 
Natural language processing
Natural language processingNatural language processing
Natural language processing
 
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
 

Kürzlich hochgeladen

Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical trainingGladiatorsKasper
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Romil Mishra
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfisabel213075
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectGayathriM270621
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfShreyas Pandit
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier Fernández Muñoz
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxStephen Sitton
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProRay Yuan Liu
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 

Kürzlich hochgeladen (20)

Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training
 
Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdf
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subject
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdf
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptx
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptx
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision Pro
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 

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.