0% found this document useful (0 votes)
44 views13 pages

Adobe Scan 19-Oct-2024

..

Uploaded by

Suneel Javali
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)
44 views13 pages

Adobe Scan 19-Oct-2024

..

Uploaded by

Suneel Javali
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/ 13

Artificial Intelligence and Expert System

Class Notes

(Unit-IV)

Natural language processing


There have been three different approaches taken in the development of natural language
understanding program.
() The use of keyword and pattern matching.

(ii) Comparing and matching the input to the real world situations.

(ii) Combined syntactic(structural) and semantic directed analysis.

The Keyword and pattern matching is the simplest. It is based on the use of sentence templates, which
contain keyword or phrases that are matched against input sentences.
Advantage: Ungrammatical but meaningful sentences are stillaccepted.
Disadvantage: No actual knowledge structures are created.

Comparing and matching the input to the real world situation is based on the use of structure such as
frames or scripts. It depe nds on the use of constraints imposed by context &world knowledge to
develop an understanding of the language inputs.

Advantage: Much of the computation required for syntactical analysis is bypassed.


Disadvantage: Asubstantial amount of specific, as well as general knowledge must be pre
stored.

In Syntactic and semantic directed analysis, knowledge structures are constructed during the syntactic
and semantic analysis of the input sentence. Parsers are used analyze individual sentences and to build
structures that can be used directly or transformed into the required knowledge formats.
Advantage: The power and versatility it provides.

Disadvantage: Large amount of computation is required.

Basic steps of Natural Language processing with suitable block diagram.


Natural languages are those spoken by people. We can break the process down into the following
pieces:

1) Morphological Analysis: Individual worlds are analyzed into their components and non word tokens,
such as punctuation are separated from the words.

2) Syntactic Analysis: Linear sequences of words are transformed into structures that show how the
words relate each other. Some word sequences may be rejected if they violate the languages rules for
how words may be combined.

3) Semantic Analysis: The structures created by the syntactic analyzer are assigned meanings.

4) Discourse Integration: The meaning of an individual sentence may depend on the sentences that
precede it and may influence the meanings of the sentence (may depend on the sentences that precede
it) that follow it.

S) Pragmatic Analysis: The structure representing what was said is reinterpreted to determine that what
was actually meant. For example, the sentence "Do you know what time it is?" should be interpreted as
a request to be told the time.

Input String Parser Output


Representation
Structure
Lexicon

Fig: Block Diagram of Natural Language Processing


Results of each of the main processes combine to form a natural language system.

Parsing: The process of determining the syntactical structure of a sentence is known as parsing. The
structure of a sentence can be represented with a syntactic tree. It converts a flat list into a hierarchical
structure. Parsers may be designed to process a sentence using either a Top-Down or a Bottom-Up
approach.
Bottom-Up Parsing begins with the sentence to be parsed and applies the grammar rules backward until
a single tree whose terminals are the words of the sentence and whose top node is the start symbol has
been produced. Consider the sentence "Kathy Jumped the Horse".

Kathy Jumped The Horse

’NJumped The Horse


>NVThe Horse

>NVART Horse

’NVART N

’NVNP

’NVP

’NP VP

’s

Top-Down Parsing begins with the start symbol and applies the grammar rules forward until the
symbols at the terminal of the tree corresponds to the components of the sentence being parsed.
Consider the sentence "Kathy Jumped the Horse".

S’ NP VP

>N VP

’Kathy VP

>Kathy V NP

>Kathy Jumped NP

’ Kathy Jumped ART N

>Kathy Jumped The N


>Kathy Jumped The Horse

Lexicon: The lexicon is a dictionary of words where each word contains some syntactic, semantic and
possibly some pragmatic information.

Draw the parse tree for the following sentences:

Sourav scored a beautiful goal.

Recursive Transition Network (RTN)

Arecursive transition network (RTN) is defined by a graph of nodes and edges. The edges are labeled
with output symbols-these are the primitives in the language. The nodes and edge structure provides
the means of combination. One of the nodes is designated the start node (indicated by an arrow
pointing into that node). One or more of the nodes may be designated as final nodes (indicated by an
inner circle). Astring is in the language if there exists some path from the start node to a final node in
the graph where the output symbols along the path edges produce the string. Asimple RTN with three
nodes and four edges that can produce four different sentences. Starting at the node marked Noun,
there are two possible edges to follow. Each edge outputs a different symbol, and leads to the node
marked Verb. From that node there are two output edges, each leading to the final node marked S.
Since there are no edges out of S, this ends the string. Hence, the RTN can produce four strings
corresponding to the four different paths from the start to final node: "Alice jumps", "Alice runs", "Bob
jumps", and "Bob runs".Recursive transition networks are more efficient than listing the strings in a
language, since the number of possible strings increases with the number of possible paths through the
graph.

Alice jumps

Noun Verb

Bob runs

Figure 2.1. Simple recursive transition network.


Consider what happens when we add the single "and" edge to the previous network to produce the
network shown in Figure 2.2 below.

and

Alice jumps

Noun Verb

Bob

Figure 2.2. RTN with a cycle.

Now, we can produce infinitely many different strings! We can follow the "and" edge back to the Noun
node to produce strings like "Alice runs and Bob jumps and Alice jumps" with as many conjuncts as we
want.

Different strings can be produced by the RTN below:


jumps
Alice eats quickly

Noun Verb Adverb

Bob runs slowly

a. How many nodes are needed for a recursive transition network that can produce exactly 8 strings?
b. How many edges are needed for a recursive transition network that can produce exactly 8 strings?
Augmented Transition Networks

An augmented transition network (ATN) is a type of graph structure used in the operational definition
of formal languages, used especially in parsing relatively complex natural languages, and having wide
application in artificial intelligence. An ATN can, theoretically, analyze the structure of any sentence,
however complicated.

Parsing with an ATN

1. Set the ATN pointer to (S] and the source pointer to the 15 word of the sentence. The ATN
pointer points to the current node.
2. Select an arc out of the current node which satisfies any associated test and, if the arc is labeled
with a word category, the current word must be a member of that category.
3. Execute any actions associated with the arc and:
If the arc is a word category, update the current position in the source sentence by one
word and change the current node to the destination of the arc
If the arc corresponds to another ATN, push the starting node of the ATN onto the ATN
pointer
If the arc is jump, chage the current node to the destination of that arc
If the arc is done, pop the current node off of the ATN pointer and set * to the value
returned by this node. If the ATN pointer is now empty and all of the text has been
processed, return *. If the ATN pointer is empty and there is remaining text, fail.
Otherwise, return to step 2.
Planning:
Definition: Generation of a sequence of actions to achieve a goal is called planning.
Planning is the process of computing several steps of a problem-solving procedure before executing any
of them. This problem can be solved by search.

Both planning and searching concerned with findinga path from a start state to a goal. The main
difference between search and planning is the representation of states:

In search, states are represented as a single entity (which may be quite a complex object, but its internal
structure is not used by the search algorithm).

In planning, states have structured representations (collections of properties) which are used by the
planning algorithm

There are two types of planners:


Progression Planner: It searches forward from the initial situation to the goal situation.
Regression Planner: It searches backward from the goal situation to the initial situation.

Representation of Planning

The representation of planning problems-states, actions, and goals-should make it possible for planning
algorithms to take advantage of the logical structure of the problem.

Representation of states. Planners decompose the world into logical conditions and represent a state as
a conjunction of positive literals.

Representation of goals. Agoal is a partially specified state, represented as a conjunction of positive


ground literals,

Representation of actions. An action is specified in terms of the preconditions that must hold before it
can be executed and the effects that ensue when it is executed. For example, an action for flying a plane
from one location to another is:

Action(Fly(p, from, to),

PRECOND:At(p,from)^ Plane(p) ^ Airport(from) ^Airport(to)


EFFECT:"At(p,from) At(p,to))

This is more properly callled an action schema, meaning that it: representsa number of different actions
that can be derived by instantiating the variables p, from, and to to different constants. In general, an
action schema consists of three parts:

The action name and parameter list-for example, Flyp, from, to)-serves to identify the action.

The precondition is a conjunction of function-free positive literals stating what must be true in a state
before the action can be executed. Any variables in the precondition must also appear in the action's
parameter list.

The effect is a conjunction of function-free literals describing how the state changes when the action is
executed.

Representation of States: Conjunction of literals

At(p, Raipur) a Plane(p) ^ Airport(Raipur) ^ Airport(Mumbai)


Representation of Goals

At(p, Mumbai)

Representation of Actions Action Schema

Action(

Fly(p,from,to), :Action Name

PRECOND: At(p,from) APlane(p) : precondition must be true

EFFECT: At(p,from) ^ At(p,to)

A planner that can represent plans in which some steps are ordered (before or after) with respect to
each other and other steps are unordered is called a partial order planner. Any planning algorithm that
can place two actions into a plan without specifying which comes first is called a partial order planner.
The alternative is a total order planner, in which plans consist of a simple list of steps. Atotally ordered
plan that is derived from a plan P by adding ordering constraints is called a linearization of P. Total
order plan search explores only strict linear sequence of actions directly connected to the start or goal.

Partiel Order Plan: Total Order Plans:

Start
E----
Start

Right
Start

Rght
Start

Lett
Start

Left
Start

Rght
Start

Let
Sock Sock Sock Sock Sock Sock
Left Right
Sock Sock
Left
Sock
Left
Sock ----
Rut
Sock
Right
Sock
Right
Shoe Shoe

LetSockOn
et
Shoe
FughtSockOn
Riçht
Shoe
--
|Rght
Shoe
Left
Shoe
Rioh! Lett
Shoe
Left
Sock Sock

Right Let Raht Len Roght


Shoe Shoe Shoe Shoe Shoe Shoe
LotShoeOn, rghuShoeOn
Finsh Finish Finsh Ensb Finish

Figue 115 A partialorder plan for puting on shoes and socks (inchiding preconditlons on
sleps), and the six possible lnearvatons of the pan
Progression Planning
Progression planners plan in a forwards direction, from the initial state to the goal. An operator is
atoms in the current
applicable to the current state if the atoms in its precondition all unify with
and
state. We generate the successors by taking the current state
" inserting the operator's positive effects (add-list), and
" deleting the operator's negative effects (delete-list).
Regression Planning
Regression planners plan in a backwards direction, from the goal to the initial state,
applying operators in reverse. Ateach point, we compute predecessor states. For example, if the
goal contains the atom holding(a), then we find all operators that have holding(x) as a positive
effect. We generate the predecessors by taking the goal and
"deleting all of the operator's positive effects, and
inserting all of the operator's preconditions.
The predecessor now acts as a subgoal: it is a state that we would like to achieve. So we compute
its predecessors. And so we continue until, if possible, we reach asubgoal all of whose atoms are
true in the initial state.

Progression vs Regression Planning:


1. Progression is data driven. It may do lots of work that is irrelevant to the goal. Regression is
goal driven, appropriate for problem solving.
2. Complexity of regression planning can be much less than that of progression planning
Partial-Order versus Total-Order Planning
A planner that can represent plans in which some steps are ordered with respect to each other but
others are unordered is a partial-order or non-linear planner.
Simple-minded planners cannot represent plans in this way: even when steps do not need to be
ordered, they are stillordered (the ordering coming from the order in which they were
determined during planning). We call these total-order or linear planners.
Plan space planning is amenable to partial-order planning in away that state space planning is
generally not.
Introduction to STRIPS

The language of STRIPS is propositional or first-order logie. The state of the world is
represented by aconjunction of literals, (but first-order literals must be ground and function
free).

The Closed World Assumption (CWA) holds: everything that is not mentioned in a state is
assumed to be false.

The current state is represented as a conjunction of literals. The goal is represented in STRIPS as
a conjunction of positive (non-negated) literals. The goal is satisfied if the current state contains
all (positive) literals in the goal. An action in is represented by a set of preconditions that must
hold before it can be executed and a set of effects that happen when it is executed.

Blocks World Planning Examples

The world consists of: A flat surface such as a tabletop


An adequate set of identical blocks which are identified by letters.
The blocks can be stacked one on one to form towers of apparently unlimited height.
The stacking is achieved using a robot arm which has fundamental operations and states which can
be assessed using logic and combined using logical operations.
The robot can hold one block at a time and only one block can be moved at a time.

The Blocks World

The blocks world is a simple world in which planning algorithms are commonly taught and
demonstrated. It comprisesa robot arm and a number of labeled wooden cubes, resting on a table.
Here is an example of an initial state and a goal state.

Initial stale Goal state

The robot is capable of four actions: stacking a block that it is holding on top of another block;
unstacking a block from another block; picking a block up from the table; and putting down a block that
it is holding onto the table.
We shall use the four actions:
UNSTACK(A,B) -- pick up clear block A
from block B;

place block A using the arm onto clear block B;


STACK(A,B)
PICKUP(A) -- lift clear block A with the empty arm;

PUTDOWN(A) -- place the held block Aonto a free space on the table.
and the five predicates:
ON(A,B) -- block A is on block B.

ONTABLE(A) -- block A is on the table.

CLEAR(A) -- block A has nothing on it.

HOLDINGIA) the arm holds block A.

ARMEMPTY -- the arm holds nothing.

Using logic but not logical notation we can say that If the arm is holding a block it is not empty
If block Ais on the table it is not on any other block If block Ais on block B,block Bis not
clear.

Gaat

start state:
ON(B, A)A ONTABLE(A)A ONTABLE(C)A ONTABLE(D)^ ARMEMPTY
goal state:
ON(C, A)A ON(B,D) ^ ONTABLE(A)^ ONTABLE(D)

we derive the following plan

1 UNSTACK(B,A)
STACK (B,D)
3. PICKUP(C)
4. STACK (C,A)

The blocks world is chosen because:


it is sufficiently simple and well behaved.
easily understood
yet still provides a good sample environment to study planning:
problems can be broken into nearly distinct subproblems
we can show how partial solutions need to be combined to form a realistic complete
solution.

You might also like