��MANGALORE INSTITUTE OF TECHNOLOGY & ENGINEERING �(A Unit of Rajalaxmi Education Trust®, Mangalore)�Autonomous Institute affiliated to VTU, Belagavi, Approved by AICTE, New Delhi�Accredited by NAAC with A+ Grade & ISO 9001:2015 Certified Institution� � � � �
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING
Course Materials
for
Subject Title : NATURAL LANGUAGE PROCESSING
Subject Code :BAI601
Semester :6
Scheme : 2022
by
Radha E G
Assistant Professor
Dept of AI and ML
MITE,Moodabidri
Contents
Course Outcomes�
At the end of the course, the student will be able to:
● Apply the fundamental concept of NLP, grammar-based language model and statistical-based language model.
● Model morphological analysis using Finite State Transducers and parsing using context-free grammar and different parsing approaches.
● Develop the Naïve Bayes classifier and sentiment analysis for Natural language problems and text classifications.
● Apply the concepts of information retrieval, lexical semantics, lexical dictionaries such as WordNet, lexical computational semantics, distributional word similarity.
● Identify the Machine Translation applications of NLP using Encode and Decoder.
Vision & Mission of the Department�
Vision
Mission
Program Outcomes�
Engineering Graduates will be able to:
6.The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice.
7.Environment and sustainability: Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
8.Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice.
9.Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary settings.
10.Communication: Communicate effectively on complex engineering activities with the engineering community and with society at large, such as, being able to comprehend and write effective reports and design documentation, make effective presentations, and give and receive clear instructions.
11.Project management and finance: Demonstrate knowledge and understanding of the engineering and management principles and apply these to one’s own work, as a member and leader in a team, to manage projects and in multidisciplinary environments.
12.Life-long learning: Recognize the need for and have the preparation and ability to engage in independent and life-long learning in the broadest context of technological change
Program Specific Outcomes & Program Education Objectives�
Program Educational Objectives (PEOs)
Program Specific Outcomes (PSOs)
CO-PO Mapping �
Mapping of COs with PO:
Correlation Levels: 1: Low 2: Medium 3: High
Course Index (C311) | PO1 | PO2 | PO3 | PO4 | PO5 | PO6 | PO7 | PO8 | PO9 | PO10 | PO11 | PO12 |
C311.1 | 3 | 3 | 2 |
| 2 |
|
|
|
|
|
| 2 |
C311.2 | 3 | 3 | 3 | 2 | 2 |
|
|
|
|
|
| 2 |
C311.3 | 3 | 3 | 3 | 2 | 3 |
|
|
|
|
|
| 2 |
C311.4 | 3 | 3 | 3 | 2 | 3 |
|
|
|
|
|
| 2 |
C311.5 | 3 | 3 | 3 | 2 | 3 |
|
|
|
|
|
| 2 |
Assignment Questions�
IA Marks Distribution & Portion for IA �
��Laboratory Mark Rubrics (If IPCC Course)�
Model 1
Introduction ,Language Modeling
Content
Chapter 1-Introduction
What is Natural Language Processing?
NLP focuses on the interaction between computers and human language, enabling machines to understand, interpret, and generate human language in a way that is both meaningful and useful.
Natural language processing (NLP) is a field of computer science and a subfield of artificial intelligence that aims to make computers understand human language.
• NLP involves a wide range of tasks and techniques to process and analyze natural language data, which can include written text or spoken language.
Some of the fundamental tasks in NLP include:
• Tokenization: Breaking down a piece of text into smaller units, such as words or subwords, which are easier to handle and analyze.
• Part-of-speech (POS) tagging: Assigning grammatical categories (e.g., noun, verb, adjective) to each word in a sentence.
• Named Entity Recognition (NER): Identifying and classifying entities (e.g., names of people, organizations, locations) in a text.
• Parsing: Analyzing the grammatical structure of sentences to understand their syntactic relationships.
• Sentiment Analysis: Determining the sentiment or emotion expressed in a piece of text (e.g., positive, negative, neutral).
• Machine Translation: Translating text from one language to another using various techniques, including rule-based, statistical, and neural machine translation.
Tokenization: Splits sentence into words.
Applications of NLP
Types of determiners
Example : The quick brown fox jumps over the lazy dog
Example 2:The thirsty dog drank all the water in the bowl.
Example 3:The small cat chased the big rat under the table.
Rationalist Approach:
Computational Linguistics
Computational linguistics is the study of language using computer models and algorithms. It combines linguistics, computer science, and artificial intelligence (AI) to analyze, process, and generate human language.
Key Areas of Computational Linguistics
Example: Chatbots, machine translation (Google Translate).
Example: Siri, Google Assistant.
Example: Analyzing customer reviews to detect positive or negative opinions.
Example: DeepL, Google Translate.
4. Computational Phonetics & Phonology – Studying how computers can analyze speech sounds.
Example: Voice recognition in smart assistants.
5. Cognitive Modeling of Language – Simulating how humans process language.
Example: AI models that predict word choice in sentences.
How It Relates to Other Linguistic Fields
The main difference between theoretical linguistics and psycholinguistics lies in their focus and approach to studying language:
Theoretical Linguistics
Psycholinguistics
1.3 LANGUAGE AND KNOWLEDGE
Language is the medium of expression in which knowledge is deciphered. Language being a medium of expression is the outer form of the content it expresses. The same content can be expressed in different languages.
Lexical analysis:
"The quick brown fox jumps over the lazy dog.“
i.Tokenization: This process splits the text into tokens (words or phrases).
ii.Normalization: Converting all tokens to a common format, usually lowercasing all words:
iii. Removing Stop Words: Stop words are common words that don't add much meaning and are usually removed in NLP tasks.
Examples of stop words are "the", "over", "and", etc. After removing stop words, the tokens might be:
["quick", "brown", "fox", "jumps", "lazy", "dog"]
iv. Lemmatization: This reduces words to their base or root form.
For example, "jumps" would be reduced to "jump":
["quick", "brown", "fox", "jump", "lazy", "dog"]
v. Part-of-Speech Tagging: Identifying the grammatical category of each token. For our sentence, it might look like this:
Syntactic analysis, also known as parsing, is the process of analyzing sentences in terms of their grammatical structure. It involves breaking down sentences into their components (words or tokens) and understanding the syntactical relationships between them.
Consider the sentence: "The quick brown fox jumps over the lazy dog."
Part-of-Speech Tagging:
Common rules for constructing parse tree include:
"The quick brown fox jumps over the lazy dog."
Example 2: The thirsty dog drank all the water in the bowl
Example 3: The small cat chased the big rat under the table
Here's the parse tree for the sentence "The small cat chased the big rat under the table." in a tree-like structure:
Example 4:She eats an apple
Example 5:the hungry tiger was looking for food.�
Example 6:The small cat is chasing a mouse."
Example 7:The small dog is barking at the cat
Semantic Analysis
Example:
Discourse analysis in Natural Language Processing (NLP) is the study of how texts and spoken language function in communicative contexts. It goes beyond sentence-level analysis to understand how sentences and larger units of text interact to create meaning. Discourse analysis involves various tasks such as identifying discourse markers, anaphora resolution, and analyzing the structure and coherence of texts.
Key Components of Discourse Analysis in NLP
Example: Anaphora Resolution in Discourse Analysis
Split the text into individual tokens:
["John", "went", "to", "the", "store", ".", "He", "bought", "some", "apples", "."]
Identify the parts of speech for each token:
[("John", "NNP"), ("went", "VBD"), ("to", "TO"), ("the", "DT"), ("store", "NN"), (".", "."), ("He", "PRP"), ("bought", "VBD"), ("some", "DT"), ("apples", "NNS"), (".", ".")]
Identify named entities: [("John", "PERSON")]
"The movie was so boring, I fell asleep.“
Literal Meaning: The movie was boring enough to make the reviewer fall asleep.
Pragmatic Meaning: The reviewer is expressing strong dissatisfaction with the movie.
In this case, pragmatic analysis helps us understand that the reviewer didn't literally fall asleep because the movie was boring, but rather, they are using hyperbole to emphasize their negative opinion.
Consider the following examples:
1.4 The Challenges of NLP
Consider the following sentence for an example;
“Raj tried to reach his friend on the mobile, but he didn’t attend”
In this sentence, we have the presence of lexical, syntactic, and anaphoric ambiguities.
Lexical ambiguity – The word “tried” means “attempted” not “judged” or “tested”.
Also, the word “reach” means “establish communication” not “gain” or “pass” or“strive”.
Syntactic ambiguity – The phrase “on the mobile” attached to “reach” and thus means“using the mobile”. It is not attached to “friend”.
1. Ambiguity
2. Complexity
3. Variability
Example: Different regions use different slang. For instance, "soda" in the US might be "pop" in some regions. NLP systems need to recognize and adapt to these variations.
4. Resource Limitations
5. Context Understanding
6. Misspellings
7. Language Differences
1.5 Language and Grammar
Types of grammar in NLP
Transformational grammar
The mapping from deep structure to surface structure is carried out by transformation.
The passive transformation rules will convert the sentence into:
The +snatcher+will +be+en+catch+by+police (figure 1.3)
Example:
"The boy is reading the book."
Apply the transformation to create a passive voice sentence:
"The book is being read by the boy."
"The book is being read by the boy."
Noun Phrase (NP): "The boy"
Verb Phrase (VP): "is reading the book"
In this structure:
In this structure:
1.6 Processing Indian Languages,
1.7 NLP Applications
Machine Translation
This refers to automatic translation of text from one language to another. In order to carry out this translation, it is necessary to have an understanding of words and phrases, grammar of the two languages involved, semantics of the languages, and world knowledge.
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.
This is the process of mapping acoustic speech signals to asset of words. The difficulties arise due to wide variations in the pronunciation of words,homonym(e.g. dear and deer ) and acoustic ambiguities (e.g.in the rest and interest).
Speech Synthesis
Speech Synthesis referes to automatic production of speech(utterance of natural language sentences). Such system can read out your email on telephone or even read out a storybook for you. In order to generate utterances, text has to be processed. So NLP remains an important component of any speech synthesis system
Natural Languages Interfaces to Databases��Natural language interfaces allow querying a structured database using natural language sentences.
From the above diagram, it is clear that a user who needs information will have to formulate a request in the form of a query in natural language. After that, the IR system will return output by retrieving the relevant output, in the form of documents, about the required information.
The step by step procedure of these systems are as follows:
Chapter 2: statistical language model
Example:
The Arabian knights
These are the fairy tales of the east
The stories of the Arabian knights are translated in many languages .
Compute using the bigram model the probability of the sentence. Include start and end symbol in your calculations.
Example Calculation
2.2.5 Paninion Framework
Karaka Theory
Model questions
Section 1: Introduction to NLP
Section 2: Language Modeling