You are on page 1of 17

ARTIFICIAL INTELLIGENCE

for
T.E. Computer Engg. / I. T

As per Revised KBCNMU Syllabus (w.e.f. 2020-2021)

Notes prepared by:


Mr. Pravin K. Patil
Assistant Professor, Computer Engineering Department

SSBT’s College of Engineering and Technology Bambhori Jalgaon

Based on Reference Book:

Elaine Rich, Kevin Knight and Shivshankar Nair "Artificial Intelligence".


3rd Edition TMH.
UNIT – IV
Understanding NLP and Expert System
Contents:
 Natural Language Processing Steps
 Learning Techniques
 Introduction to Expert System
o Architecture of Expert System
o Expert System Shell
o Knowledge Acquisition in Expert System
 Understanding Constraint Satisfaction
o Waltz Algorithm
o Constraint Determination
o Trihedral Figure Labelling

Natural Language Processing Steps


 Natural Language Processing, usually shortened as NLP, is a branch of artificial
intelligence that deals with the interaction between computers and humans using
the natural language.
 Following are the important steps in NLP:
1. Morphological Analysis
2. Syntactic Analysis
3. Semantic Analysis
4. Discourse Integration
5. Pragmatic Analysis
1. Morphological Analysis
 Individual words are analysed into their components and nonword tokens such as
punctuation marks are separated from the words.
 For example, consider the sentence, “I want to print Bill’s .init file.”
 In the above sentence, morphological analysis will do two things:
 Pull apart the word “Bill’s” into its 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.
 In addition to this, it will also assign syntactic categories to all the word in the
sentence.

2. Syntactic Analysis
 Linear sequence of words is transformed into structures that show how the words
relate to each other.
 Some word sequences may be rejected if they violate the language’s rules for how
the words may be combined.
 For example the English Syntactic Analyser would reject the sentence “Boy the go the
to store”
 Syntactic Analysis exploits the results of morphological analysis to build a structural
description of a sentence.
 The goal of this process called “Parsing”, is to convert the flat list of words that form
a sentence into a structure that defines the units that are represented by that flat list of
words.
 The following figure shows the parse tree for the sentence ““I want to print Bill’s .init
file.”

 Here RM denotes Reference Markers. Each reference markers corresponds to some


entity that has been mentioned in the sentence.
 These reference markers provide a place to accumulate information about the entities.
This information can be used in further steps of the process.

3. Semantic Analysis
 Here the structures created by syntactic analysis are assigned meaninigs.
 In other words, mapping is made between the syntactic structures and the objects in
the task domain.
 Semantic Analysis must do two things:
o It must map individual words into appropriate objects in the knowledge base
or database.
o It must create correct structures to correspond to the way the meanings of
individual words combine with each other.

4. Discourse Integration
 Consider the sentence ““I want to print Bill’s .init file.”
 In this sentence, we do not exactly know, to whom, the pronoun “I” or the proper
noun “Bill” refers to.
 To pin down these references, we need a model of discourse integration from which
we can learn who the current user “I” is and who the person named “Bill” is.
 Once the current reference for Bill is known we can also find the reference to actual
file whose extension is .init.

5. Pragmatic Analysis
 Pragmatic Analysis is part of the process of extracting information from text.
 Specifically, it's the portion that focuses on taking structures set of text and figuring
out what the actual meaning was.
 Pragmatic Analysis is very important with respect to extracting the context of the
information.
 Many times the context in which the sentence was said or written is very important.
So Pragmatic Analysis becomes a crucial part of NLP process.

Q. Explain NLP steps in detail (KBCNMU December 2019 Examination)

Learning Techniques
1. Rote Learning
 Rote learning is defined as the memorization of information based on repetition.
 The two best examples of rote learning are the alphabet and numbers.
 Slightly more complicated examples include multiplication tables and spelling words.
 At the high-school level, scientific elements and their chemical numbers must be
memorized by rote.
 And, many times, teachers use rote learning without even realizing they do so.
 Memorization isn’t the most effective way to learn, but it’s a method many students
and teachers still use.
 A common rote learning technique is preparing quickly for a test, also known as
cramming.

 Advantages of Rote Learning


o Ability to quickly recall basic facts
o Helps develop foundational knowledge
 Disadvantages of Rote Learning
o Can be repetitive
o Easy to lose focus
o Doesn’t allow for a deeper understanding of a subject
o Doesn’t encourage the use of social skills
o No connection between new and previous knowledge
o May result in wrong impression or understanding a concept

 When rote memorization is applied as the main focus of learning, it is not considered
higher-level thought or critical thinking.
 Opponents to rote memorization argue that creativity in students is stunted and
suppressed, and students do not learn how to think, analyze or solve problems.
 These educators believe, instead, that a more associative or constructive learning
should be applied in the classroom. If the majority of the student’s day is spent on
repetition, the foundation for learning becomes shaky.
 Rote learning is the cornerstone of higher-level thinking and should not be ignored.
 Especially in today’s advanced technological world, rote memorization might be even
more important than ever
 If you can easily access the information when performing a certain task, the brain is
free to make major leaps in learning.

2. Learning by taking Advice


 This is a simple form of learning. Suppose a programmer writes a set of instructions
to instruct the computer what to do, the programmer is a teacher and the computer is a
student. Once learned (i.e. programmed), the system will be in a position to do new
things.
 The advice may come from many sources: human experts, internet to name a few.
This type of learning requires more inference than rote learning. The knowledge must
be transformed into an operational form before stored in the knowledge base.
Moreover the reliability of the source of knowledge should be considered.

Expert System

 An expert system is a system that employs human knowledge captured in a computer


to solve problems that ordinarily require human expertise.
 A computer program that emulates the behaviour of human experts who are solving
real-world problems associated with a particular domain of knowledge.
 An expert system is a computer system that emulates, or acts in all respects, with the
decision-making capabilities of a human expert.
 The expert systems are the computer applications developed to solve complex
problems in a particular domain, at the level of extra-ordinary human intelligence and
expertise.

 Architecture of Expert Systems


The Architecture of Expert System include following 3 major components −
1. Knowledge Base
2. Inference Engine
3. User Interface

Fig. Architecture of expert system

1. Knowledge Base
 It contains domain-specific and high-quality knowledge. Knowledge is required to
exhibit intelligence. The success of any ES majorly depends upon the collection of
highly accurate and precise knowledge
 The data is collection of facts. The information is organized as data and facts about the
task domain. Data, information, and past experience combined together are termed
as knowledge.
 The knowledge base of an ES is a store of both, factual and heuristic knowledge.
1. Factual Knowledge − It is the information widely accepted by the Knowledge
Engineers and scholars in the task domain.
2. Heuristic Knowledge − It is about practice, accurate judgement, one’s ability of
evaluation, and guessing.
 Knowledge representation is the method used to organize and formalize the
knowledge in the knowledge base. It is in the form of IF-THEN-ELSE rules
 The success of any expert system majorly depends on the quality, completeness, and
accuracy of the information stored in the knowledge base.
 The knowledge base is formed by readings from various experts, scholars, and
the Knowledge Engineers

2. Inference Engine
 Use of efficient procedures and rules by the Inference Engine is essential in deducting
a correct, flawless solution.
 In case of knowledge-based ES, the Inference Engine acquires and manipulates the
knowledge from the knowledge base to arrive at a particular solution.
 In case of rule based ES, it −
 Applies rules repeatedly to the facts, which are obtained from earlier rule
application.
 Adds new knowledge into the knowledge base if required.
 Resolves rules conflict when multiple rules are applicable to a particular case
 To recommend a solution, the Inference Engine uses the following strategies −
I. Forward Chaining
II. Backward Chaining

 Forward Chaining
 It is a strategy of an expert system to answer the question, “What can happen
next?”
 Here, the Inference Engine follows the chain of conditions and derivations and
finally deduces the outcome.
 It considers all the facts and rules, and sorts them before concluding to a solution.
 This strategy is followed for working on conclusion, result, or effect.
 For example, prediction of share market status as an effect of changes in interest
rates.

Fig. Forward Chaining


 Backward Chaining
 With this strategy, an expert system finds out the answer to the question, “Why
this happened?”
 On the basis of what has already happened, the Inference Engine tries to find out
which conditions could have happened in the past for this result.
 This strategy is followed for finding out cause or reason.
 For example, diagnosis of blood cancer in humans.

Fig. Backward Chaining

3. User Interface
 User interface provides interaction between user of the ES and the ES itself. It is
generally Natural Language Processing so as to be used by the user who is well-
versed in the task domain. The user of the ES need not be necessarily an expert in
Artificial Intelligence.
 It explains how the ES has arrived at a particular recommendation. The explanation
may appear in the following forms −
 Natural language displayed on screen.
 Verbal narrations in natural language.
 Listing of rule numbers displayed on the screen.
 Requirements of Efficient ES User Interface
 It should help users to accomplish their goals in shortest possible way.
 It should be designed to work for user’s existing or desired work practices.
 Its technology should be adaptable to user’s requirements; not the other way
round.
 It should make efficient use of user input.

Q. Draw and Explain architecture of Expert System with its advantages (KBCNMU December
2019 Examination)
Expert System Shell

 A new expert system can be developed by adding domain knowledge to the shell. The
figure depicts generic components of expert system.

 Expert System Shell:

 Knowledge acquisition system: It is the first and fundamental step. It helps to collect
the experts knowledge required to solve the Problems and build the knowledge base.

 Knowledge Base: This component is the heart of expert systems. It stores all factual
and heuristic knowledge about the application domain. It provides with the various
representation techniques for all the data.

 Inference mechanism: Inference engine is the brain of the expert system. This
component is mainly responsible for generating inference from the given knowledge
from the knowledge base and produce line of reasoning in turn the result of the user's
query.

 Explanation subsystem: This part of shell is responsible for explaining or justifying


the final or intermediate result of user query. It is also responsible to justify need of
additional knowledge.

 User interface: It is the means of communication with the user. It decides the utility
of expert system.

 Building expert systems by using shells has significant advantages. It is always


advisable to use shell to develop expert system as it avoids building the system from
scratch.
 To build an expert system using system shell, one needs to enter all necessary
knowledge about a task domain into the shell.

 Initially each expert system that was built, was created right from scratch. But after
several systems has been built in this way, it became clear that they had a lot in
common.

 In particular, since the systems were built as asset of rules combined with an
interpreter for those representations, it was possible to separate the interpreter from
the domain specific knowledge and thus create a system that could be used to
construct a new expert system, by adding the new knowledge corresponding to the
new problem domain. Such resulting interpreters are called shells.

 Earlier expert system shells provide mechanisms for knowledge representation,


reasoning and explanation. Later on tools for knowledge Acquisition were added.

 But with the time, expert systems needed to do something else as well. They need to
make it easy to integrate expert system with other programs.

 They need to access the corporate databases, embedded with larger application
programs etc. So the most important feature of expert system shell is to provide easy
to use interface.
Q. Write a short note on Expert System Shell (KBCNMU December 2019 Examination)

Knowledge Acquision in Expert System

 Knowledge acquisition is an activity of knowledge engineering that is very important


in the initial phase of system.
 It deals with building the fundamental knowledge base and updating it in the
application phase of the system.
 The domain knowledge acquired initially is a combination of factual knowledge and
the heuristic knowledge.
 The development phase of knowledge acquisition includes the activities that occur
before acquiring knowledge from domain experts, such as domain identification,
domain knowledge conceptualization, knowledge formalization and encoding, and
knowledge refinement and validation.
 The knowledge acquisition module is responsible for identifying, acquiring, and
storing new knowledge that would be useful in decision making.
 This module contains the following agents:
o Acquisition agent
o Mapping agent
o Storage agent.
 Based on their day-to-day activities, stakeholders may either identify new knowledge
that needs to be gathered or create knowledge that could be used by others within the
organization.
 Any knowledge that is generated needs to be represented and stored in such a manner
that it is readily accessible and usable by others.
 The mapping and storage agents are responsible for generating the internal
representation of the knowledge so that they can be stored, organized, disseminated,
and used by other stakeholders and applications.
 The knowledge within the repositories can be organized based on subject or a specific
taxonomy.

Understanding Constraint Satisfaction

 In artificial intelligence, constraint satisfaction is the process of finding a solution


to a set of constraints that impose conditions that the variables must satisfy.
 Constraint satisfaction problems (CSPs) are mathematical questions defined as a set
of objects whose state must satisfy a number of constraints or limitations. .
 Example:
1. Consider a Sudoku game with some numbers filled initially in some squares.
2. You are expected to fill the empty squares with numbers ranging from 1 to 9
in such a way that no row, column or a block has a number repeating itself.
3. This is a very basic constraint satisfaction problem.
4. You are supposed to solve a problem keeping in mind some constraints.
5. The remaining squares that are to be filled are known as variables, and the
range of numbers (1-9) that can fill them is known as a domain. Variables
take on values from the domain.
6. The conditions governing how a variable will choose its domain are known as
constraints.
 A constraint satisfaction problem (CSP) is a problem that requires its solution
within some limitations or conditions also known as constraints. It consists of the
following:
1. A finite set of variables which stores the solution (V = {V1, V2, V3,....., Vn})
2. A set of discrete values known as domain from which the solution is picked
(D = {D1, D2, D3,.....,Dn})
3. A finite set of constraints (C = {C1, C2, C3,......, Cn})
 Also, note that all these sets should be finite except for the domain set.
 Each variable in the variable set can have different domains.
 For example, consider the Sudoku problem again. Suppose that a row, column and
block already have 3, 5 and 7 filled in. Then the domain for all the variables in that
row, column and block will be {1, 2, 4, 6, 8, 9}.
 A problem to be converted to CSP requires the following steps:
o Step 1: Create a variable set.
o Step 2: Create a domain set.
o Step 3: Create a constraint set with variables and domains (if possible)
after considering the constraints.
o Step 4: Find an optimal solution

 Waltz’s Algorithm
There are two important steps in the use of constraints in problem solving:

o Analyse the problem domain to determine the actual constraints.


o Solve the problem by applying a constraint satisfaction algorithm.

 Consider for example a three dimensional line drawing. The analysis process is to
determine the object described by the lines. The geometric relationships between
different types of line junctions helped to determine the object types.

Fig. Three dimensional polyhedral junction types

 In waltz’s algorithm, labels are assigned to lines of various types-say concave edges
are produced by two adjacent touching surfaces which duce a concave (less than 180
Degrees).
 Conversely, convex edges produce a convexly viewed depth (greater than 180
degrees), and a boundary edge outlines a surface that obstracts other objects.
 To label a concave edge, a minus sign is used.
 Convex edges one labeled with a plus sign, and a right or left arrow is used to
label the boundary edges.
 By restricting vertices to be the intersection of three object faces, it is possible to
reduce the number of basic vertex types to only four :
The L, The Arrow, The T, The Fork

Fig. Valid junction labels for three-dimensional shapes.

 When a three-dimensional object is viewed from all possible positions, the four
junction types, together with the valid edge labels, give rise to sixteen different
permissible junction configurations as shown in figure
 Geometric constraints, together with a consistent labeling scheme, can simplify the
object identification process.

Algorithm:
1. Find the lines at the border of the scene boundary and label them. These lines can
be found by finding an outline such that no vertices are outside it. We do this first
because this labeling will impose additional constraints on the other labelings in
the figure.
2. Number the vertices of the figure to be analyzed. These numbers will correspond
to the order in which the vertices will be visited during the labeling process. To
decide on a numbering, do the following:
a. Start at any vertex on the boundary of the figure. Since boundary lines are
known, the vertices involving them are more highly constrained than are
interior ones.
b. Move from the vertex along the boundary to an adjacent unnumbered vertex
and continue until all boundary vertices have been numbered.
c. Number interior vertices by moving from a numbered vertex to some adjacent
unnumbered one. By always labeling a vertex next to one that has already
been labeled, maximum use can be made of the constraints.
3. Visit each vertex V in order and attempt to label it by doing the following:
a. Using the set of possible vertex labelings given in the list of 18 physically
possible trihedral vertices, attach to V a list of its possible labelings.
b. See whether some of these labelings can be eliminated on the basis of local
constraints. To do this, examine each vertex A that is adjacent to V and
that has already been visited. Check to see that for each proposed labeling
for V, there is a way to label the line between V and A in such a way that
at least one of the labelings listed for A is still possible. Eliminated from
V’s list any labeling for which is not the case.
c. Use the set of labelings just attached to V to contain the labels at vertices
adjacent to V. For each vertex A that was visited in the last step, do the
following:
i. Eliminated all labelings of A that are not consistent with at least
one labeling of V.
ii. If any labelings were eliminated, continue constraint propagation
by examining the vertices adjacent to A and checking for
consistency with the restricted set of labeling now attached to A
iii. Continue to propagate until there are no adjacent labeled vertices or
until there are no adjacent labeled vertices or until there is no
change made to the existing set of labeling.

 A set of labelling rules which facilitates this process can be developed for different
classes of objects. The following rules will apply for many polyhedral objects.
o The arrow should be directed to mark boundaries by traversing the object in a
clockwise direction.
o Unbroken lines should have the same label assigned at both ends.
o When a fork is labelled with a + edge, it must have all three edges label as + .
o Arrow junctions which have a+ label on both bard edges must also have a +
label on the shaft.
 These rules can be applied to a polygonal object as given in figure

Fig. Example of Object labeling.

 Starting with any edge having an object face on its right, the external boundary is
labelled with the + in a clockwise direction. Interior lines are then labelled with + or -
consistent with the other labelling rules.
 To see how constraint satisfaction algorithm works waltz; consider the image
drawing of a pyramid as given in below figure. At the right side of the pyramid are
all possible labelling for the four junctions A, B, C and D.

 Using these labels as mutual constraints on connected junctions, permissible labels for
the whole pyramid can be determined. The constraint satisfaction procedure works
as follows.
 Starting at an arbitrary junction, say A, a record of all permissible labels is made for
that junction. An adjacent junction is then chosen, say, B and labels which are
inconsistent with the line AB are then eliminated from the permissible A and B lists.
In this case, the line joining B can only be a +, - or an up arrow consequently, two of
the possible
 A labelling can be eliminated and the remaining are
 Choosing junction c next, we find that the BC constraints are satisfied by all of the B
and C labelling, so on reduction is possible with this step. On the other hand, the line
AC must be labelled as – or as an up left-arrow to be consistent. Therefore, an
additional label for A can be eliminated to reduce the remainder to the following.

 This new restriction on a now permits the elimination of one B labelling to maintain
consistency. Thus, the permissible B labelling remaining is now

 This reduction in turn, places a new restriction on BC, permitting the elimination of
one C label, since BC must now be labelled as a + only. This leaves the remaining C
labels as show in side diagram.
 Moving now to junction d, we see that of the six possible D leadings, only three
satisfy the BD constraint of up or down arrow.
 Continuing with the above procedure, we see that further label eliminations are not
possible since all constraints have been satisfied. This process is completed by finding
the different combinations of unique labelling that can be assigned to the figure. An
enumerations of the remaining label shows that it is possible to find only three
different labelling.
Q. Explain Waltz Algorithm with its limitations (KBCNMU December 2019 Examination)

You might also like