NLP Unit-1 Notes
NLP Unit-1 Notes
UNIT - I
i. Finding the Structure of Words:
Introduction
Methods
Complexity of the Approaches
Performances of the Approaches
NATURAL LANGUAGE PROCESSING
Humans communicate through some form of language either by text or speech.
To make interactions between computers and humans, computers need to understand natural languages used by
humans.
Natural language processing is all about making computers learn, understand, analyse, manipulate and interpret
natural(human) languages.
NLP stands for Natural Language Processing, which is a part of Computer Science, Human
language, and Artificial Intelligence.
Processing of Natural Language is required when you want an intelligent system like robot to perform as per your
instructions, when you want to hear decision from a dialogue based clinical expert system, etc.
The ability of machines to interpret human language is now at the core of many applications that we use every day
- chatbots, Email classification and spam filters, search engines, grammar checkers, voice assistants, and social
language translators.
The input and output of an NLP system can be Speech or Written Text
Definition
Branch of Artificial Intelligence that helps computers to understand, interpret and manipulate human language.
Components of NLP
There are two components of NLP, Natural Language Understanding (NLU)
and Natural Language Generation (NLG).
Natural Language Understanding (NLU) which involves transforming human
language into a machine-readable format.
It helps the machine to understand and analyse human language by extracting the
text from large data such as keywords, emotions, relations, and semantics.
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.
The NLU is harder than NLG.
NLP Terminology
Phonology − It is study of organizing sound systematically.
Morphology: The study of the formation and internal structure of words.
Morpheme − It is primitive unit of meaning in a language.
Syntax: The study of the formation and internal structure of sentences.
Semantics: The study of the meaning of sentences.
Pragmatics − It deals with using and understanding sentences in different situations
and how the interpretation of the sentence is affected.
Discourse − It deals with how the immediately preceding sentence can affect the
interpretation of the next sentence.
World Knowledge − It includes the general knowledge about the world.
Steps in NLP
There are general five steps :
1. Lexical Analysis
2. Syntactic Analysis (Parsing)
3. Semantic Analysis
4. Discourse Integration
5. Pragmatic Analysis
1 . LEXICAL ANALYSIS
The first phase of NLP is the Lexical Analysis.
This phase scans the source code as a stream of characters and converts it into meaningful
lexemes.
It divides the whole text into paragraphs, sentences, and words.
For example, a word like “uneasy” can be broken into two sub-word tokens as “un-
easy”.
2. Syntactic Analysis (Parsing) –
Syntactic Analysis is used to check grammar, word arrangements, and
5. 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.
Example: "Open the door" is interpreted as a request instead of an
order.
Finding the Structure of Words
Human language is a complicated thing.
We use it to express our thoughts, and through language, we receive information and infer its
meaning.
Trying to understand language all together is not a viable approach.
Linguists have developed whole disciplines that look at language from different perspectives
and at different levels of detail.
The point of morphology, for instance, is to study the variable forms and functions of words,
The syntax is concerned with the arrangement of words into phrases, clauses, and sentences.
Word structure constraints due to pronunciation are described by phonology,
The conventions for writing constitute the orthography of a language.
The meaning of a linguistic expression is its semantics, and etymology and
lexicology cover especially the evolution of words and explain the semantic,
morphological, and other links among them.
Words are perhaps the most intuitive units of language, yet they are in general
tricky to define.
For reasons of generality, linguists prefer to analyze won’t as two syntactic words, or tokens,
each of which has its independent role and can be reverted to its normalized form.
The structure of won’t could be parsed as will followed by not.
In English, this kind of tokenization and normalization may apply to just a limited set of
cases, but in other languages, these phenomena have to be treated in a less trivial manner.
• In Arabic or Hebrew, certain tokens are concatenated in writing
with the preceding or the following ones, possibly changing
their forms as well.
• The underlying lexical or syntactic units are thereby blurred into one compact string
of letters and no longer appear as distinct words.
• Tokens behaving in this way can be found in various languages and are often
called clitics.
• In the writing systems of Chinese, Japanese, and Thai, whitespace is not used to
separate words.
Lexemes
By the term word, we often denote not just the one linguistic form in the given
context but also the concept behind the form and the set of alternative forms that
can express it.
Such sets are called lexemes or lexical items, and they constitute the lexicon of a
language.
Lexemes can be divided by their behaviour into the lexical categories of verbs, nouns,
adjectives, conjunctions, particles, or other parts of speech.
The citation form of a lexeme, by which it is commonly identified, is also called its
lemma.
When we convert a word into its other forms, such as turning the singular mouse into
the plural mice or mouses, we say we inflect the lexeme.
When we transform a lexeme into another one that is morphologically related,
regardless of its lexical category, we say we derive the lexeme: for instance, the
nouns receiver and reception are derived from the verb to receive.
Example: Did you see him? I didn’t see him. I didn’t see anyone.
• Example presents the problem of tokenization of didn’t and the investigation of the
internal structure of anyone.
• In the paraphrase I saw no one, the lexeme to see would be inflected into the
form saw to reflect its grammatical function of expressing positive past tense.
• Likewise, him is the oblique case form of he or even of a more abstract lexeme
representing all personal pronouns.
• In the paraphrase, no one can be perceived as the minimal word
synonymous with nobody.
• The difficulty with the definition of what counts as a word need not pose a
problem for the syntactic descriM ptoiorn
phifew
meesunderstand no one as two
closely connected tokens treated as one fixed element
Morphology
Morphology is the domain of linguistics that
analyses the internal structure of words.
Morphological analysis – exploring the structure of words
Words are built up of minimal meaningful elements called morphemes:
played = play-ed
cats = cat-s
unfriendly = un-friend-ly
Two types of morphemes:
i Stems: play, cat, friend ii
Affixes: -ed, -s, un-, -ly
Two main types of affixes:
i Prefixes precede the stem: un-
ii Suffixes follow the stem: -ed, -s, un-, -ly
Stemming = find the stem by stripping off affixes
play = play
replayed = re-play-ed
computerized = comput-er-ize-d
Problems in morphological processing
Inflectional morphology: inflected forms are constructed from base forms and inflectional
affixes.
Inflection relates different forms of the same word
Lemma Singular Plural
cat cat cats
dog dog dogs
knife knife knives
sheep sheep sheep
mouse mouse mice
Derivational morphology: words are constructed from roots (or stems) and derivational
affixes:
inter+national = international
international+ize = internationalize
internationalize+ation = internationalization
The simplest morphological process concatenates morphs one by one, as in dis-
agree-ment-s, where agree is a free lexical morpheme and the other elements are
bound grammatical morphemes contributing some partial meaning to the whole word.
in a more complex scheme, morphs can interact with each other, and their forms may
become subject to additional phonological and orthographic changes denoted as
morphophonemic.
The alternative forms of a morpheme are termed allomorphs.
Typology
Morphological typology divides languages into groups by characterizing the prevalent
morphological phenomena in those languages.
It can consider various criteria, and during the history of linguistics, different classifications
have been proposed.
Let us outline the typology that is based on quantitative relations between words, their
morphemes, and their features:
Isolating, or analytic, languages include no or relatively few words that would comprise more
than one morpheme (typical members are Chinese, Vietnamese, and Thai; analytic tendencies
are also found in English).
Synthetic languages can combine more morphemes in one word and are further
divided into agglutinative and fusional languages.
Agglutinative languages have morphemes associated with only a single function at a
time (as in Korean, Japanese, Finnish, and Tamil, etc.)
Fusional languages are defined by their feature-per-morpheme ratio higher than one
(as in Arabic, Czech, Latin, Sanskrit, German, etc.).
In accordance with the notions about word formation processes mentioned earlier, we
can also find out using concatenative and nonlinear:
Concatenative languages linking morphs and morphemes one after another.
Nonlinear languages allowing structural components to merge nonsequentially to
apply tonal morphemes or change the consonantal or vocalic templates of words.
Morphological Typology
Morphological typology is a way of classifying the languages of the world that groups
languages according to their common morphological structures.
The field organizes languages on the basis of how those languages form words by
combining morphemes.
The morphological typology classifies languages into two broad classes of synthetic languages
and analytical languages.
The synthetic class is then further sub classified as either agglutinative languages or fusional
languages.
Analytic languages contain very little inflection, instead relying on features like word order and
auxiliary words to convey meaning.
Synthetic languages, ones that are not analytic, are divided into two
categories: agglutinative and fusional languages.
• Agglutinative languages rely primarily on discrete particles(prefixes, suffixes, and infixes) for
inflection, ex: inter+national = international, international+ize = internationalize.
• While fusional languages "fuse" inflectional categories together, often allowing one word
ending to contain several categories, such that the original root can be difficult to extract
(anybody, newspaper).
Issues and Challenges
Irregularity: word forms are not described by a prototypical linguistic model.
Ambiguity: word forms be understood in multiple ways out of the context of their
discourse.
Productivity: is the inventory of words in a language finite, or is it unlimited?
Morphological parsing tries to eliminate the variability of word forms to provide higher-
level linguistic units whose lexical and morphological properties are explicit and well
defined.
It attempts to remove unnecessary irregularity and give limits to ambiguity, both of
which are present inherently in human language.
By irregularity, we mean existence of such forms and structures that are not described
appropriately by a prototypical linguistic model.
Some irregularities can be understood by redesigning the model and improving its
rules, but other lexically dependent irregularities often cannot be generalized
Ambiguity is indeterminacy (not being interpreted) in interpretation of expressions of
language.
Morphological modelling also faces the problem of productivity and creativity in language, by
which unconventional but perfectly meaningful new words or new senses are coined.
Irregularity
Morphological parsing is motivated by the quest for generalization and abstraction in the
world of words.
Immediate descriptions of given linguistic data may not be the ultimate ones, due to either
their inadequate accuracy or inappropriate complexity, and better formulations may be
needed.
The design principles of the morphological model are therefore very important.
In Arabic, the deeper study of the morphological processes that are in effect during inflection
and derivation, even for the so-called irregular words, is essential for mastering the whole
morphological and phonological system.
With the proper abstractions made, irregular morphology can be seen as merely enforcing
some extended rules, the nature of which is phonological, over the underlying or prototypical
regular word forms.
Morphophonemic templates capture morphological processes by just organizing stem
patterns and generic affixes without any context-dependent variation of the affixes or ad hoc
modification of the stems.
The merge rules, indeed very neatly or effectively concise, then ensure that such structured
representations can be converted into exactly the surface forms, both orthographic and
phonological, used in the natural language.
Applying the merge rules is independent of and irrespective of any grammatical parameters
or information other than that contained in a template.
Most morphological irregularities are thus successfully removed.
Ambiguity
Morphological ambiguity is the possibility that word forms be understood in multiple
ways out of the context of their discourse (communication in speech or writing).
Words forms that look the same but have distinct functions or meaning are called
homonyms.
Ambiguity is present in all aspects of morphological processing and language
processing at large.
Table arranges homonyms on the basis of their behaviour with different endings.
Systematic homonyms arise as verbs combined with endings in Korean
1.Dictionary Lookup
2.Finite state Morphology
3. Unification based Morphology
4.Functional Morphology
1. Dictionary Lookup
Morphological parsing is a process by which word forms of a language are
associated with
corresponding linguistic descriptions.
Morphological systems that specify these associations by merely
enumerating(is the act or process of making or stating a list of things one
after another) them case by case do not offer any generalization means.
Likewise for systems in which analyzing a word form is reduced to looking it up
verbatim in word lists, dictionaries, or databases, unless they are constructed
by and kept in sync with more sophisticated models of the language.
In this context, a dictionary is understood as a data structure that
directly enables obtaining some precomputed results, in our case word
analyses.
The data structure can be optimized for efficient lookup, and the
results can be shared. Lookup operations are relatively simple and
usually quick.
Dictionaries can be implemented, for instance, as lists, binary search trees, tries, hash
tables, and so on.
Because the set of associations between word forms and their desired descriptions is
declared by plain enumeration, the coverage of the model is finite and the generative
potential of the language is not exploited.
Despite all that, an enumerative model is often sufficient for the given purpose, deals easily
with exceptions, and can implement even complex morphology.
For instance, dictionary-based approaches to Korean depend on a large dictionary of all
possible combinations of allomorphs and morphological alternations.
These approaches do not allow development of reusable morphological rules, though.
2. Finite-State Morphology
By finite-state morphological models, we mean those in which the specifications written by
human programmers are directly compiled into finite-state transducers.
The two most popular tools supporting this approach, XFST (Xerox Finite-State Tool) and
LexTools.
Finite-state transducers are computational devices extending the power of finite-state
automata.
They consist of a finite set of nodes connected by directed edges labeled with pairs of input
and output symbols.
In such a network or graph, nodes are also called states, while edges are called arcs.
Traversing the network from the set of initial states to the set of final states along the arcs is
equivalent to reading the sequences of encountered input symbols and writing the sequences
of corresponding output symbols.
The set of possible sequences accepted by the transducer defines the inpu
language; the set of possible sequences emitted by the transducer defines the outpu
language.
Input Input Morphological parsed output
Cats cat +N +PL
Cat cat +N +SG
Cities city +N +PL
Geese goose +N +PL
Goose goose +N +SG) or (goose +V)
Gooses goose +V +3SG
mergin merge +V +PRES-PART
g
Caught (caught +V +PAST-PART) or (catch +V +PAST)
Finite state automata for cats,dogs,fox
For example, a finite-state transducer could translate the infinite regular language consisting of the
words vnuk, pravnuk, prapravnuk, ... to the matching words in the infinite regular language defined
by grandson, great-grandson, great-great-grandson.
In finite-state computational morphology, it is common to refer to the input word forms as surface strings and to
the output descriptions as lexical strings, if the transducer is used for morphological analysis, or vice versa, if it is
used for morphological generation.
• In English, a finite-state transducer could analyze the surface string children into the lexical
string child [+plural], for instance, or generate women from woman [+plural].
Relations on languages can also be viewed as functions. Let us have a relation R, and let us denote by [Σ] the set
of all sequences over some set of symbols Σ, so that the domain and the range of R are subsets of [Σ].
We can then consider R as a function mapping an input string into a set of output strings, formally denoted by this
type signature, where [Σ] equals String:
A theoretical limitation of finite-state models of morphology is the problem of capturing reduplication of words or
their elements (e.g., to express plurality) found in several human languages.
Finite-state technology can be applied to the morphological modeling of isolating and agglutinative languages in a
quite straightforward manner. Korean finite-state models are discussed by Kim, Lee and Rim, and Han, to mention
a few.
3. Unification-Based Morphology
The concepts and methods of these formalisms are often closely connected to those
of logic programming.
In finite-state morphological models, both surface and lexical forms are by themselves
unstructured strings of atomic symbols.
In higher-level approaches, linguistic information is expressed by more appropriate
data structures that can include complex values or can be recursively nested if
needed.
Morphological parsing P thus associates linear forms φ with alternatives of structured
content ψ, cf.
Erjavec argues that for morphological modelling, word forms are best captured by
regular expressions, while the linguistic content is best described through typed
feature structures.
Feature structures can be viewed as directed acyclic graphs.
A node in a feature structure comprises a set of attributes whose values can be
Nodes are associated with types, and atomic values are attributeless nodes
distinguished by their type.
Instead of unique instances of values everywhere, references can be used to establish
value instance identity.
Feature structures are usually displayed as attribute-value matrices or as nested
symbolic expressions.
Unification is the key operation by which feature structures can be merged into a more
informative feature structure.
Unification of feature structures can also fail, which means that the information in them
is mutually incompatible.
Morphological models of this kind are typically formulated as logic programs, and
unification is used to solve the system of constraints imposed by the model.
Advantages of this approach include better abstraction possibilities for developing a
morphological grammar as well as elimination of redundant information from it.
Unification-based models have been implemented for Russian, Czech, Slovene,
Persian, Hebrew, Arabic, and other languages.
4. Functional Morphology
Functional morphology defines its models using principles of functional programming
and type theory.
It treats morphological operations and processes as pure mathematical functions and
organizes the linguistic as well as abstract elements of a model into distinct types of
values and type classes.
Though functional morphology is not limited to modelling particular types of
morphologies in human languages, it is especially useful for fusional morphologies.
Linguistic notions like paradigms, rules and exceptions, grammatical categories and
parameters, lexemes, morphemes, and morphs can be represented intuitively(without
conscious reasoning; instinctively) and succinctly(in a brief and clearly expressed
manner) in this approach.
Functional morphology implementations are intended to be reused as programming
libraries capable of handling the complete morphology of a language and to be
incorporated into various kinds of applications.
Morphological parsing is just one usage of the system, the others being
morphological generation, lexicon browsing, and so on.
we can describe inflection I, derivation D, and lookup L as functions of these generic
type
𝑌= 𝑎 𝑟𝑔 𝑚 𝑎 𝑥
𝑃 𝑌𝑋
𝑦
Discriminative sequence models, however, focus on features that categorize the differences between the labelling of that
examples.
GENERATIVE SEQUENCE CLASSIFICATION METHODS
Most commonly used generative sequence classification method for topic and
sentence is the hidden Markov model (HMM).
The probability in equation 2.2 is rewritten as the following, using the Bayes rule:
Where NumNewTerms(b) returns the number of terms in block b seen the first time in text.
2.2.3Discriminative Sequence Classification Methods
In segmentation tasks, the sentence or topic decision for a given example(word, sentence,
paragraph) highly depends on the decision for the examples in its vicinity.
Discriminative sequence classification methods are in general extensions of local
discriminative models with additional decoding stages that find the best assignment of labels
by looking at neighbouring decisions to label.
Conditional random fields(CRFs) are extension of maximum entropy, SVM struct is an
extension of SVM, and maximum margin Markov networks(M3N) are extensions of HMM.
CRFs are a class of log-linear models for labelling structures.
Contrary to local classifiers that predict sentences or topic boundaries independently, CRFs
can oversee the whole sequence of boundary hypotheses to make their decisions.
Complexity of the Approaches
The approaches described here have advantages and disadvantages.
In a given context and under a set of observation features, one approach may be better than
other.
These approaches can be rated in terms of complexity (time and memory) of their training
and prediction algorithms and in terms of their performance on real-world datasets.
In terms of complexity, training of discriminative approaches is more complex than training
of generative ones because they require multiple passes over the training data to adjust for
feature weights.
However, generative models such as HELMs can handle multiple orders of magnitude larger
training sets and benefits, for instance, from decades of news wire transcripts.
On the other hand, they work with only a few features (only words for HELM) and do not
cope well with unseen events.
1. List and explain the challenges of morphological models. Mar 2021 [7]
2. Discuss the importance and goals of Natural Language Processing. Mar 2021 [8]
3. List the applications and challenges in NLP. Sep 2021 [7]
4. Explain any one Morphological model. Sep 2021 [8]
5. Discuss about challenging issues of Morphological model. Sep 2021 [7]
6. Differentiate between surface and deep structure in NLP with suitable examples. Sep 2021
[8] 7.Give some examples for early NLP systems. Sep 2021 [7]
8. Explain the performance of approaches in structure of documents? Sep 2021 [15]
9. With the help of a neat diagram, explain the representation of syntactic structure. Mar 2021 [8]
10.Elobarate the models for ambiguity resolution in Parsing. Mar 2021 [7]
11.Explain various types of parsers in NLP? Sep 2021 [8]
12.Discuss multilingual issues in detail. Sep 2021 [7]
13. Given the grammar S->AB|BB, A->CC|AB|a, B->BB|CA|b, C->BA|AA|b, word w=‘aabb’. Applay top down parsing test, word
can be generated or not. Sep 2021 [8]
14. Explain Tree Banks and its role in parsing. Sep 2021 [7]
List the applications in NLP.
Applications of NLP:
• Information retrieval & web search
• Grammar correction & Question answering
• Sentiment Analysis.
• Text Classification.
• Chatbots & Virtual Assistants.
• Text Extraction.
• Machine Translation.
• Text Summarization.
• Market Intelligence.
• Auto-Correct.
Discuss the importance and goals of Natural Language Processing.