0% found this document useful (0 votes)
33 views45 pages

NLP: Techniques and Applications

Natural language processing (NLP) is the ability of computers to understand human language. NLP involves analyzing text for things like parts of speech and semantics. Common NLP applications include language translation, voice assistants, and sentiment analysis.

Uploaded by

aangisanghvi03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views45 pages

NLP: Techniques and Applications

Natural language processing (NLP) is the ability of computers to understand human language. NLP involves analyzing text for things like parts of speech and semantics. Common NLP applications include language translation, voice assistants, and sentiment analysis.

Uploaded by

aangisanghvi03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

UNIT-5: NLP AND

APPLICATIONS
Natural language processing (NLP) is the ability of a computer
program to understand human language as it is spoken. NLP is a
component of artificial intelligence (AI).

It is a set of computational techniques for analyzing and representing


naturally occurring texts (at one or more levels) for the purpose of
achieving human-like language processing for a range of applications.

Benefits of NLP:

 Improved accuracy and efficiency of documentation.


 The ability to automatically make a readable summary text.
 Useful for personal assistants such as Alexa.
 Allows an organization to use chatbots for customer support.
 Easier to perform sentiment analysis.
 Challenges associated with NLP
 NLP has not yet been wholly perfected. For example, semantic
analysis can still be a challenge for NLP.
 Other difficulties include the fact that abstract use of language
is typically tricky for programs to understand.
 For instance, NLP does not pick up sarcasm easily. These topics
usually require the understanding of the words being used and
the context in which the way they are being used.
 As another example, a sentence can change meaning depending
on which word the speaker puts stress on.
 NLP is also challenged by the fact that language, and the way
people use it, is continually changing.
What is NLP used for?

Natural Language Processing is the driving force behind the following


common applications:
 Language translation applications such as Google Translate
 Word Processors such as Microsoft Word and Grammarly that
employ NLP to check grammatical accuracy of texts.
 Interactive Voice Response (IVR) applications used in call centers
to respond to certain users’ requests.
 Personal assistant applications such as OK Google, Siri, Cortana,
and Alexa.
NATURAL LANGUAGE
UNDERSTANDING
Raw speech signal

• Speech recognition
Sequence of words spoken
• Syntactic analysis using knowledge of the grammar
Structure of the sentence

• Semantic analysis using info. about meaning of words


Partial representation of meaning of sentence

• Pragmatic analysis using info. about context


Final representation of meaning of sentence
I. PHASES OF NLP
 Phonological Analysis
 Morphological analysis
 Lexical Analysis (Parser, syntactic analysis)
 Semantic analysis (transform into a logical form,
semantic network, etc.)
 Discourse analysis
 Pragmatic analysis
NLP - Prof. Carolina Ruiz
Phonology : This level is applied only if the text origin is a speech. It
deals with the interpretation of speech sounds within and across
words. Speech sound might give a big hint about the meaning of a
word or a sentence. It takes an acoustic waveform as input and
produce a string of words as output.

Lexical Analysis − It involves identifying and analyzing the structure


of words. Lexicon of a language means the collection of words and
phrases in a language. Lexical analysis is dividing the whole chunk
of txt into paragraphs, sentences, and words.

Syntactic Analysis (Parsing) − It involves analysis of words in the


sentence for grammar and arranging words in a manner that shows
the relationship among the words. The sentence such as “The school
goes to boy” is rejected by English syntactic analyzer.
Semantic Analysis − It draws the exact meaning or the dictionary
meaning from the text. The text is checked for meaningfulness. It is done
by mapping syntactic structures and objects in the task domain. The
semantic analyzer disregards sentence such as “hot ice-cream”.

Discourse Integration − The meaning of any sentence depends upon the


meaning of the sentence just before it. In addition, it also brings about
the meaning of immediately succeeding sentence.

Pragmatic Analysis − During this, what was said is re-interpreted on


what it actually meant. It involves deriving those aspects of language
which require real world knowledge.
SYNTACTIC ANALYSIS
Rules of syntax (grammar) specify the possible organization of
words in sentences and allows us to determine sentence’s
structure(s)
• “John saw Mary with a telescope”
• John saw (Mary with a telescope)
• John (saw Mary with a telescope)
Parsing: given a sentence and a grammar
• Checks that the sentence is correct according with the
grammar and if so returns a parse tree representing the
structure of the sentence
1. Syntax
Syntax refers to the arrangement of words in a sentence such that
they make grammatical sense.

In NLP, syntactic analysis is used to assess how the natural


language aligns with the grammatical rules.
SYNTACTIC ANALYSIS
- GRAMMAR
sentence -> noun_phrase, verb_phrase
noun_phrase -> proper_noun
noun_phrase -> determiner, noun
verb_phrase -> verb, noun_phrase
proper_noun -> [mary]
noun -> [apple]
verb -> [ate]
determiner -> [the]
SYNTACTIC ANALYSIS
- PARSING
sentence

noun_phrase verb_phrase

proper_noun verb noun_phrase

determiner noun

“Mary” “ate” “the” “apple”


Here are some syntax techniques that can be used:

Lemmatization: It entails reducing the various inflected forms


of a word into a single form for easy analysis.

Morphological segmentation: It involves dividing words into


individual units called morphemes.

Word segmentation: It involves dividing a large piece of


continuous text into distinct units.
Part-of-speech tagging: It involves identifying the part of
speech for every word.
Parsing: It involves undertaking grammatical analysis for the
provided sentence.
Sentence breaking: It involves placing sentence boundaries on a
large piece of text.
Stemming: It involves cutting the inflected words to their root
form.
MORPHOLOGICAL ANALYSIS
 In morphology is the study of words, how they are formed, and their
relationship to other words in the same language.

 It analyzes the structure of words and parts of words, such as stems,


root words, prefixes, and suffixes.

 Morphology also looks at parts of speech, and the ways context can
change a word's pronunciation and meaning.

 For example, the word preregistration can be morphologically


analyzed into three separate morphemes: the prefix “pre”, the root
“registra”, and the suffix “tion”.
Morphology is the study of the structure and formation of
words. Its most important unit is the morpheme, which is defined
as the "minimal unit of meaning". Consider a word like:
"unhappiness". This has three parts:
Parsing
s --> np, vp. det -->[a]. det --> [an].
np --> det, noun. det --> [the].
np --> proper_noun. noun --> [apple].
vp --> v, ng. noun --> [orange].
vp --> v. proper_noun --> [john].
proper_noun --> [mary].
v --> [eats].
v --> [loves].
Eg. john eats an apple.

proper_noun v det noun

np

np vp

s
Example:
S → NP VP
NP → DET N | DET ADJ N
VP → V NP

Lexicon −
• DET → a | the
• ADJ → beautiful | perching
• N → bird | birds | grain | grains
• V → peck | pecks | pecking
Semantics
• It is concerned with the meaning of words and how to combine
words into meaningful phrases and sentences.

• Semantic Analysis − It draws the exact meaning or the


dictionary meaning from the text.

• The text is checked for meaningfulness. It is done by mapping


syntactic structures and objects in the task domain. The
semantic analyzer disregards sentence such as “hot ice-cream”.
Here are some techniques in semantic analysis:

• Named entity recognition (NER): It involves determining the


parts of a text that can be identified and categorized into preset
groups. Examples of such groups include names of people and
names of places.
• Word sense disambiguation: It involves giving meaning to a
word based on the context.
• Natural language generation: It involves using databases to
derive semantic intentions and convert them into human
language.
SEMANTIC ANALYSIS

Generates (partial) meaning/representation of the


sentence from its syntactic structure(s)
Compositional semantics: meaning of the sentence
from the meaning of its parts:
• Sentence: A tall man likes Mary
• Representation: x man(x) & tall(x) & likes(x,mary)
Grammar + Semantics
• Sentence (Smeaning)->
noun_phrase(NPmeaning),verb_phrase(VPmeaning),
combine(NPmeaning,VPmeaning,Smeaning)
Semantic analysis
john eats an apple. Sem. Cat (Ontology)
proper_noun v det noun object
[person: john] λYλX eat(X,Y) [apple]

np animated non-anim
[apple]

np vp person animal
food … [person: john] eat(X, [apple])

s vertebral …
fruit …
eat([person: john], [apple])
Discourse analysis
• Anaphora
He hits the car with a stone. It bounces back.
• Understanding a text
– Who/when/where/what … are involved in an event?
– How to connect the semantic representations of different
sentences?
– What is the cause of an event and what is the consequence of
an action
• “…groups of statements which structure the way a thing is
thought, and the way we act on the basis of that thinking.
• “In other words, discourse is a particular knowledge about the
world that shapes how the world is understood and how things
are done in it.”
PRAGMATICS
Pragmatics − It deals with using and understanding sentences in
different situations and how the interpretation of the sentence is
affected.

During this, what was said is re-interpreted on what it actually


meant. It involves deriving those aspects of language which require
real world knowledge.
II. APPLICATIONS OF AI (NLP)
1) Neural Network
2) Pattern Recognition
3) Computer Vision
1. NEURAL NETWORK
Artificial neural networks (ANN) or connectionist systems are
computing systems vaguely inspired by the biological neural
networks that constitute animal brains.

Such systems "learn" to perform tasks by considering examples,


generally without being programmed with task-specific rules.
HISTORY
 Warren McCulloch and Walter Pitts (1943) opened the subject by creating a
computational model for neural networks.
 In the late 1940s, D. O. Hebb created a learning hypothesis based on the
mechanism of neural plasticity that became known as Hebbian learning.
 Farley and Wesley A. Clark[ (1954) first used computational machines, then
called "calculators", to simulate a Hebbian network.
 Rosenblatt (1958) created the perceptron.
 The first functional networks with many layers were published
by Ivakhnenko and Lapa in 1965, as the Group Method of Data Handling.
 The basics of continuous back-propagation were derived in the context
of control theory by Kelley in 1960 and by Bryson in 1961, using principles
of dynamic programming.
BIOLOGICAL NEURON
 A biological neuron model, also known as a spiking neuron
model, is a mathematical description of the properties of
certain cells in the nervous system that generate sharp
electrical potentials, roughly one millisecond in duration.
 You brain is a neural network, one really complex neural
network. It has 1011 neurons. And each of these neurons is
connected to approximately 104 other neurons.
 These interconnected neurons use electrical pulses to
"communicate" with each other.
Input: The nerve cell has several dendrites. These dendrites gather
information from the axon of other nerve cells.
The point of contact of the axon and the dendrite is called a synapse. It
is at the synapse that the electrical pulse actually jumps from the axon to
the dendrite. This happens by means of a complex chemical reaction.

Output: The output of the neuron is an electrical voltage. And this


voltage is decided by the cell body, based on the inputs it receives. This
output goes to several other nerve cells, where it acts as an input. Thus,
this single neuron can "contribute" to controlling several other neurons.
CHARACTERSTICS
 It is neurally implemented mathematical model
 It contains huge number of interconnected processing elements called
neurons to do all operations
 Information stored in the neurons are basically the weighted linkage of
neurons
 The input signals arrive at the processing elements through
connections and connecting weights.
 It has the ability to learn , recall and generalize from the given data by
suitable assignment and adjustment of weights.
 The collective behavior of the neurons describes its computational
power, and no single neuron carries specific information .
ARTIFICIAL NEURAL NETWORK
APPLICATIONS

1) Handwriting Recognition
The idea of using feed-forward neural networks to recognize
handwritten characters is straightforward.
The bitmap pattern of the handwritten character is input, with the
correct letter or digit as the desired output. Such programs need
the user to train the network by providing the program with their
handwritten patterns.
The two common applications of handwriting recognition are:
 Optical character recognition for data entry
 Validation of signatures on a bank cheque.
2) Traveling Salesman Problem – Neural networks can also
solve the traveling salesman problem. But this is to a certain
degree of approximation only.
A neural network algorithm such as a genetic algorithm starts
with random orientation of the network, to solve the problem.
This algorithm chooses a city in a random manner each time and
finds the nearest city.
Thus, this process continues several times. After every iteration,
the shape of the network changes and network converges to a ring
around all the cities.
3) Stock Exchange Prediction
We can also use neural networks in currency prediction, business
failure prediction, debt risk assessment, and credit approval.
Companies such as MJ Futures claim amazing 199.2% returns
over a 2-year period using their neural network prediction
methods.
2. PATTERN RECOGNITION
Pattern recognition is the process of recognizing patterns by using
machine learning algorithm.
Pattern recognition can be defined as the classification of data based
on knowledge already gained or on statistical information extracted
from patterns and/or their representation.
One of the important aspects of the pattern recognition is its application
potential.

Examples: Speech recognition, speaker identification, multimedia


document recognition (MDR), automatic medical diagnosis.
In a typical pattern recognition application, the raw data is processed and
converted into a form that is amenable for a machine to use. Pattern
recognition involves classification and cluster of patterns.
TRAINING AND LEARNING IN
PATTERN RECOGNITION
Learning is a phenomena through which a system gets trained and
becomes adaptable to give result in an accurate manner. Learning is the
most important phase as how well the system performs on the data
provided to the system depends on which algorithms used on the data.
Entire dataset is divided into two categories, one which is used in
training the model i.e. Training set and the other that is used in testing
the model after training, i.e. Testing set.
Training set:
Training set is used to build a model. It consists of the set of images
which are used to train the system.
Training rules and algorithms used give relevant information on how
to associate input data with output decision.
The system is trained by applying these algorithms on the dataset, all
the relevant information is extracted from the data and results are
obtained.
Generally, 80% of the data of the dataset is taken for training data.
Testing set:
Testing data is used to test the system. It is the set of data which is used
to verify whether the system is producing the correct output after being
trained or not.
Generally, 20% of the data of the dataset is used for testing. Testing data
is used to measure the accuracy of the system.
Example: a system which identifies which category a particular flower
belongs to, is able to identify seven category of flowers correctly out of
ten and rest others wrong, then the accuracy is 70 %.
3. COMPUTER VISION

Computer vision is an interdisciplinary scientific field that deals with


how computers can be made to gain high-level understanding
from digital images or videos. From the perspective of engineering, it
seeks to automate tasks that the human visual system can do.
APPLICATIONS
 Automatic inspection, e.g., in manufacturing applications;
 Assisting humans in identification tasks, e.g., a species
identification system;
 Controlling processes, e.g., an industrial robot;
 Detecting events, e.g., for visual surveillance or people counting, e.g.,
in the restaurant industry;
 Interaction, e.g., as the input to a device for computer-human
interaction;
 Modeling objects or environments, e.g., medical image analysis or
topographical modeling;
 Navigation, e.g., by an autonomous vehicle or mobile robot; and
 Organizing information, e.g., for indexing databases of images and
image sequences.

You might also like