AI Notes - Natural Language Processing
AI Notes - Natural Language Processing
AI Notes - Natural Language Processing
many to many.
(c) Some noise or disturbing factors are also there.
(d) The level of interaction of the source components may be complex one.
(e) The problem solver might be unknown about some more complex problems.
(f) The intermediary actions may also be unavailable.
Consider an example of an English sentence which is being used for communication with a
keyword based data retrieval system. Suppose I want to know all about the temples in India. So I
would need to be translated into a representation such as The above sentence is a simple sentence
for which the corresponding representation may be easy to implement. But what for the complex
queries?
This type of complex queries can be modeled with the conceptual dependency representation
which is more complex than that of simple representation. Constructing these queries is very
difficult since more informationare to be extracted. Extracting more information will require
some more knowledge. Also the type of mapping process is not quite easy to the problem solver.
Understanding is the process of mapping an input from its original form to a more useful one.
The simplest kind of mapping is “one-toone”.
In one-to-one mapping each different problems would lead to only one solution. But there are
very few inputs which are one-to-one. Other mappings are quite difficult to implement. Many-to-
one mappings are frequent is that free variation is often allowed, either because of the physical
limitations of that produces the inputs or because such variation simply makes the task of
generating the inputs.
Many to one mapping require that the understanding system know about all the ways that a target
representation can be expressed in the source language. One-to-many mapping requires a great
deal of domain knowledge in order to make the correct choice among the available target
representation.
The mapping process is simplest if each component can be mapped without concern for the other
components of the statement. If the number of interactions increases, then the complexity of the
problem will increase. In many understanding situations the input to which meaning should be
assigned is not always the input that is presented to the under stander.
Because of the complex environment in which understanding usually occurs, other things often
interfere with the basic input before it reaches the under stander. Hence the understanding will be
more complex if there will be some sort of noise on the inputs.
104
Pull apart the word “Bill’s” into proper noun “Bill” and the possessive suffix “’s”
Recognize the sequence “.init” as a file extension that is functioning as an adjective in the
sentence.
This process will usually assign syntactic categories to all the words in the sentence.
Syntactic Analysis
A syntactic analysis must exploit the results of the morphological analysis to build a
structural description of the sentence.
The goal of this process, called parsing, is to convert the flat list of words that form the
sentence into a structure that defines the units that represented by that flat list.
The important thing here is that a flat sentence has been converted into a hierarchical
structure. And that the structure corresponds to meaning units when a semantic analysis
performed.
Reference markers (set of entities) shown in the parenthesis in the parse tree.
Each one corresponds to some entity that has mentioned in the sentence.
These reference markers are useful later since they provide a place in which to
accumulate information about the entities as we get it.
Semantic Analysis
The semantic analysis must do two important things:
1. It must map individual words into appropriate objects in the knowledge base or
database.
2. It must create the correct structures to correspond to the way the meanings of the
individual words combine with each other.
Discourse Integration
Specifically, we do not know whom the pronoun “I” or the proper noun “Bill” refers to.
To pin down these references requires an appeal to a model of the current discourse
context, from which we can learn that the current user is USER068 and that the only
person named “Bill” about whom we could be talking is USER073.
Once the correct referent for Bill known, we can also determine exactly which file
referred to.
Pragmatic Analysis
The final step toward effective understanding is to decide what to do as a result.
105
One possible thing to do to record what was said as a fact and done with it.
For some sentences, a whose intended effect is clearly declarative, that is the precisely
correct thing to do.
But for other sentences, including this one, the intended effect is different.
We can discover this intended effect by applying a set of rules that characterize
cooperative dialogues.
The final step in pragmatic processing to translate, from the knowledge-based
representation to a command to be executed by the system.
Syntactic Processing
Syntactic Processing is the step in which a flat input sentence converted into a
hierarchical structure that corresponds to the units of meaning in the sentence. This
process called parsing.
It plays an important role in natural language understanding systems for two reasons:
1. Semantic processing must operate on sentence constituents. If there is no syntactic
parsing step, then the semantics system must decide on its own constituents. If
parsing is done, on the other hand, it constrains the number of constituents that
semantics can consider.
2. Syntactic parsing is computationally less expensive than is semantic processing.
Thus it can play a significant role in reducing overall system complexity.
Although it is often possible to extract the meaning of a sentence without using
grammatical facts, it is not always possible to do so.
Almost all the systems that are actually used have two main components:
1. A declarative representation, called a grammar, of the syntactic facts about the
language.
2. A procedure, called parser that compares the grammar against input sentences to
produce parsed structures.
Grammars and Parsers
The most common way to represent grammars is a set of production rules.
The first rule can read as “A sentence composed of a noun phrase followed by Verb
Phrase”; the Vertical bar is OR; ε represents the empty string.
Symbols that further expanded by rules called non-terminal symbols.
Symbols that correspond directly to strings that must found in an input sentence called
terminal symbols.
Grammar formalism such as this one underlies many linguistic theories, which in turn
provide the basis for many natural language understanding systems.
Pure context-free grammars are not effective for describing natural languages.
NLPs have less in common with computer language processing systems such as
compilers.
Parsing process takes the rules of the grammar and compares them against the input
sentence.
The simplest structure to build is a Parse Tree, which simply records the rules and how
they matched.
Every node of the parse tree corresponds either to an input word or to a non-terminal in
our grammar.
Each level in the parse tree corresponds to the application of one grammar rule.
106
Example for Syntactic Processing – Augmented Transition
Network
Syntactic Processing is the step in which a flat input sentence is converted into a hierarchical
structure that corresponds to the units of meaning in the sentence. This process called parsing.
It plays an important role in natural language understanding systems for two reasons:
1. Semantic processing must operate on sentence constituents. If there is no syntactic
parsing step, then the semantics system must decide on its own constituents. If parsing is
done, on the other hand, it constrains the number of constituents that semantics can
consider.
2. Syntactic parsing is computationally less expensive than is semantic processing. Thus it
can play a significant role in reducing overall system complexity.
Example: A Parse tree for a sentence: Bill Printed the file
107
Procedures that build structures that will form part of the final parse.
Procedures that perform arbitrary tests on current input and sentence components that
have identified.
Semantic Analysis
The structures created by the syntactic analyzer assigned meanings.
A mapping made between the syntactic structures and objects in the task domain.
Structures for which no such mapping is possible may rejected.
The semantic analysis must do two important things:
It must map individual words into appropriate objects in the knowledge base or
database.
It must create the correct structures to correspond to the way the meanings of the
individual words combine with each other. Semantic Analysis AI
Producing a syntactic parse of a sentence is only the first step toward understanding it.
We must produce a representation of the meaning of the sentence.
Because understanding is a mapping process, we must first define the language into
which we are trying to map.
There is no single definitive language in which all sentence meaning can describe.
The choice of a target language for any particular natural language understanding
program must depend on what is to do with the meanings once they constructed.
Choice of the target language in Semantic Analysis AI
There are two broad families of target languages that used in NL systems,
depending on the role that the natural language system playing in a larger system:
When natural language considered as a phenomenon on its own, as for example
when one builds a program whose goal is to read the text and then answer
questions about it. A target language can design specifically to support language
processing.
When natural language used as an interface language to another program (such as
a db query system or an expert system), then the target language must legal input
to that other program. Thus the design of the target language driven by the
backend program.
108
3. Parts of actions. Consider the text:
John went on a business trip to New York.
He left on an early morning flight.
Taking a flight should recognize as part of going on a trip.
4. Entities involved in actions. Consider the text:
My house was broken into last week.
Moreover, They took the TV and the stereo.
The pronoun “they” should recognize as referring to the burglars who broke into
the house.
5. Elements of sets. Consider the text:
The decals we have in stock are stars, the moon, item and a flag.
I’ll take two moons.
Moons mean moon decals.
6. Names of individuals:
Dev went to the movies.
7. Causal chains
There was a big snow storm yesterday.
So, The schools closed today.
8. Planning sequences:
Sally wanted a new car
She decided to get a job.
9. Implicit presuppositions:
Did Joe fail CS101?
The major focus is on using following kinds of knowledge:
The current focus of the dialogue.
Also, A model of each participant’s current beliefs.
Moreover, The goal-driven character of dialogue.
The rules of conversation shared by all participants.
109
The learning procedures used during machine learning automatically focus on the most
common cases, whereas when writing rules by hand it is often not at all obvious where
the effort should be directed.
Automatic learning procedures can make use of statistical inference algorithms to
produce models that are robust to unfamiliar input (e.g. containing words or structures
that have not been seen before) and to erroneous input (e.g. with misspelled words or
words accidentally omitted). Generally, handling such input gracefully with hand-written
rules—or more generally, creating systems of hand-written rules that make soft
decisions—is extremely difficult, error-prone and time-consuming.
Systems based on automatically learning the rules can be made more accurate simply by
supplying more input data. However, systems based on hand-written rules can only be
made more accurate by increasing the complexity of the rules, which is a much more
difficult task. In particular, there is a limit to the complexity of systems based on hand-
crafted rules, beyond which the systems become more and more unmanageable.
However, creating more data to input to machine-learning systems simply requires a
corresponding increase in the number of man-hours worked, generally without significant
increases in the complexity of the annotation process.
Spell Checking
Spell checking is one of the applications of natural language processing that impacts billions of
users daily. A good introduction to spell checking can be found on Peter Norvig’s webpage. The
article introduces a simple 21-line spell checker implementation in Python combining simple
language and error models to predict the word a user intended to type. The language model
estimates how likely a given word `c` is in the language for which the spell checker is
designed, this can be written as `P(C)`. The error model estimates the probability `P(w|c)`
of typing the misspelled version `w` conditionally to the intention of typing the correctly
spelled word `c`.The spell checker then returns word `c` corresponding to the highest value of
`P(w|c)P(c)` among all possible words in the language.
Module 3
LEARNING
Learning is the improvement of performance with experience over time.
Learning element is the portion of a learning AI system that decides how to modify the
performance element and implements those modifications.
We all learn new knowledge through different methods, depending on the type of material to be
learned, the amount of relevant knowledge we already possess, and the environment in which the
learning takes place. There are five methods of learning . They are,
1. Memorization (rote learning)
2. Direct instruction (by being told)
3. Analogy
4. Induction
110