0% found this document useful (0 votes)
7 views10 pages

Ai Unit 4

Uploaded by

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

Ai Unit 4

Uploaded by

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

Artificial Intelligence unit 4

Natural Language Processing (NLP)

What is NLP?
NLP stands for Natural Language Processing. It is the branch of
Artificial Intelligence that gives the ability to machine understand
and process human languages. Human languages can be in the
form of text or audio format.
It helps developers to organize knowledge for performing tasks
such as translation, automatic summarization, Named
Entity Recognition (NER), speech recognition, relationship
extraction, and topic segmentation.

History of NLP

Natural Language Processing started in 1950 When Alan


Mathison Turing published an article in the name Computing
Machinery and Intelligence.
It is based on Artificial intelligence. It talks about automatic
interpretation and generation of natural language.

the technology evolved, different approaches have come


to deal with NLP tasks.

 Heuristics-Based NLP:
Artificial Intelligence unit 4

 This is the initial approach of NLP. It is based on defined


rules. Which comes from domain knowledge and
expertise.
Example: regex

 Statistical Machine learning-based NLP:


 It is based on statistical rules and machine learning
algorithms.
 In this approach, algorithms are applied to the data and
learned from the data, and applied to various tasks.
Examples: Naive Bayes, support vector machine (SVM),
hidden Markov model (HMM), etc.

 Neural Network-based NLP:


 This is the latest approach that comes with the evaluation
of neural network-based learning, known as Deep
learning.
 It provides good accuracy, but it is a very data-hungry
and time-consuming approach.
 It requires high computational power to train the model.
Furthermore, it is based on neural network architecture.
Examples: Recurrent neural networks (RNNs), Long short-term
memory networks (LSTMs), Convolutional neural networks
(CNNs), Transformers, etc.

Components of NLP
There are two components of Natural Language Processing:
 Natural Language Understanding
 Natural Language Generation

1. Natural Language Understanding (NLU)

Natural Language Understanding (NLU) helps the machine to


understand and analyse human language by extracting the
metadata from content such as concepts, entities, keywords,
emotion, relations, and semantic roles.
Artificial Intelligence unit 4

2. 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.

Applications of NLP
The applications of Natural Language Processing are as follows:
 Text and speech processing like-Voice assistants – Alexa,
Siri, etc.
 Text classification like Grammarly, Microsoft Word, and
Google Docs
 Information extraction like-Search engines like
DuckDuckGo, Google
 Chatbot and Question Answering like:- website bots
 Language Translation like:- Google Translate
 Text summarization

Phases of Natural Language Processing

NLP Libraries
 NLTK
 Spacy
 Gensim
 fastText
 Stanford toolkit (Glove)
 Apache OpenNLP

Advantages of NLP
o NLP helps users to ask questions about any subject and get a direct
response within seconds.

o NLP offers exact answers to the question means it does not offer
unnecessary and unwanted information.
Artificial Intelligence unit 4
o NLP helps computers to communicate with humans in their
languages.

o It is very time efficient.

o 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:

o NLP may not show context.

o NLP is unpredictable

o NLP may require more keystrokes.

o 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.

Context-Free Grammar
Artificial Intelligence unit 4

Context Free Grammar is formal grammar, the syntax or structure of


a formal language can be described using context-free grammar
(CFG), a type of formal grammar. The grammar has four tuples:
(V,T,P,S).

A grammar is said to be the Context-free grammar if every


production is in the form of

 And the left-hand side of the G, here in the example, can only
be a Variable, it cannot be a terminal.
 But on the right-hand side here it can be a Variable or Terminal
or both combination of Variable and Terminal.
For example, the grammar A = { S, a, b } having productions:
 Here S is the starting symbol.
 {a, b} are the terminals generally represented by small
characters.
 S is the variable.

but

Lets consider the string “aba” and and try to derive the given
grammar from the productions given. we start with
symbol S, apply production rule S->bSa and then S->aS (S-
>a) to get the string “aba”.
Artificial Intelligence unit 4

What is parse tree?


A parse tree, also known as a syntax tree, is a tree-like
representation of a string’s semantics according to a grammar.
The root is the start symbol and the leaves are terminals. It is
used to validate nested data structure in JSON format, and used
verify the syntax of the source code.

What is the difference between deterministic and


non-deterministic context-free grammars?
A deterministic context-free grammar can be parsed using
deterministic pushdown automata (DPDA) and each step in it is
determined uniquely. Whereas Non-deterministic context-free
grammar requires Non-deterministic pushdown automata (NPDA)
and each step in it has many options.

Limitations of Context-Free Grammar


Context-Free Grammar can be less efficient because of the
exponential time complexity
And the less precise error reporting as CFGs error reporting system
is not that precise that can give more detailed error messages and
information.

Semantic Analysis – NLP


Introduction to Semantic Analysis
Artificial Intelligence unit 4

Semantic Analysis is a subfield of Natural Language Processing


(NLP) that attempts to understand the meaning of Natural
Language.
Understanding Natural Language might seem a straightforward
process to us as humans. However, due to the vast complexity and
subjectivity involved in human language, interpreting it is quite a
complicated task for machines.
Semantic Analysis of Natural Language captures the meaning of
the given text while taking into account context, logical structuring
of sentences and grammar roles.

Parts of Semantic Analysis


Semantic Analysis of Natural Language can be classified into two
broad parts:
1. Lexical Semantic Analysis: Lexical Semantic Analysis involves
understanding the meaning of each word of the text individually. It
basically refers to fetching the dictionary meaning that a word in
the text is deputed to carry.
2. Compositional Semantics Analysis: Although knowing the
meaning of each word of the text is essential, it is not sufficient to
completely understand the meaning of the text.

For example, consider the following two sentences:


 Sentence 1: Students love GeeksforGeeks.
 Sentence 2: GeeksforGeeks loves Students.
Although both these sentences 1 and 2 use the same set of root
words {student, love, geeksforgeeks}, they convey entirely
different meanings.
Hence, under Compositional Semantics Analysis, we try to
understand how combinations of individual words form the
meaning of the text.

Tasks involved in Semantic Analysis


1. Word Sense Disambiguation
2. Relationship Extraction
Artificial Intelligence unit 4

Word Sense Disambiguation:

In Natural Language, the meaning of a word may vary as per its


usage in sentences and the context of the text. Word Sense
Disambiguation involves interpreting the meaning of a word based
upon the context of its occurrence in a text.
Relationship Extraction:
Another important task involved in Semantic Analysis is Relationship
Extracting. It involves firstly identifying various entities present in
the sentence and then extracting the relationships between those
entities.

Elements of Semantic Analysis


1. Hyponymy: A specific instance of a general term.

 Example: Color → Red, Blue, Green.

2. Homonymy: Same spelling, unrelated meanings.

 Example: Rose (flower) vs. Rose (past of rise).

3. Synonymy: Different words, similar meanings.

 Example: Big and Large.

4. Antonymy: Words with opposite meanings.

 Example: Hot and Cold.

5. Polysemy: Same word, closely related meanings.

 Example: Man (human species) vs. Man (adult male).

6. Meronomy: Part-whole relationship.

Example: Wheel is a part of Car.

Basic Units of Semantic System:


1. Entity: An entity refers to a particular unit or individual
in specific such as a person or a location. For example
GeeksforGeeks, Delhi, etc.
2. Concept: A Concept may be understood as a
generalization of entities. It refers to a broad class of
Artificial Intelligence unit 4

individual units. For example Learning Portals, City,


Students.
3. Relations: Relations help establish relationships
between various entities and concepts. For example:
‘GeeksforGeeks is a Learning Portal’, ‘Delhi is a City.’,
etc.
4. Predicate: Predicates represent the verb structures of
the sentences.

Approaches to Meaning Representations:

Now that we are familiar with the basic understanding of


Meaning Representations, here are some of the most popular
approaches to meaning representation:
1. First-order predicate logic (FOPL)
2. Semantic Nets
3. Frames
4. Conceptual dependency (CD)
5. Rule-based architecture
6. Case Grammar
7. Conceptual Graphs

Semantic Analysis Techniques

Text Classification
In-Text Classification, our aim is to label the text according to the
insights we intend to gain from the textual data.
For example:
 In Sentiment Analysis, .
 In Topic Classification,
 In Intent Classification,

Text Extraction

In-Text Extraction, we aim at obtaining specific information from


our text.
For Example,
 In Keyword Extraction, we try to obtain the essential
words that define the entire document.
 In Entity Extraction, we try to obtain all the entities
involved in a document.
Artificial Intelligence unit 4

Significance of Semantics Analysis


 Semantic Analysis: A vital aspect of NLP for understanding
and interpreting textual data.
 Textual Insights: Helps organizations extract meaningful
insights from vast textual information.
 Business Applications: Provides valuable data to drive
business decisions and strategies.
 Automation: Reduces manual effort by enabling machines to
interpret and process text effectively.

You might also like