0% found this document useful (0 votes)
22 views70 pages

Unit 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views70 pages

Unit 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 70

ARTIFICIAL

INTELLIGENCE
B. Keerthana
Assistant Professor
CSE department
GVPCE(A)
UNIT-5

Natural language processing:


Introduction, sentence analysis phases, types of parsers, semantic analysis
Expert system:
Introduction, Phases in building Expert systems, Expert systems
architecture, Expert systems vs Traditional systems, Rule based expert
systems, Applications of expert systems, List of shells and tools
INTRODUCTION

● NLP is a component of Artificial Intelligence


● NLP focuses on the communication between humans and computers
● The goal of NLP is to enable computers to understand and interpret
human language in a way that is similar to how humans process
language
● It is a driving force behind things like virtual assistants, speech
recognition, sentiment analysis, automatic text summarization, machine
translation and much more
● Just as humans have different sensors, such as ears to hear and eyes to
see computers have programs to read and microphones to collect audio
PHASES OF NLP

1. DATA PREPROCESSING
2. ALGORITHM DEVELOPMENT
1. DATA PREPROCESSING

Data Preprocessing : Data preprocessing involves preparing and "cleaning" text


data for machines to be able to analyze it.. There are several ways this can be done,
including:
● Lower case: Making all the text lower case is one of the simplest and most
effective forms of text preprocessing
1. DATA PREPROCESSING (Cont..)

● Tokenization: Text is broken down into smaller units

● Stop word: Common words are removed from text. Words like ‘the’, ‘is’, ‘a’ have
less value and add noise to the text data.
1. DATA PREPROCESSING (Cont..)

● Stemming: Stemming is the process of reducing a word to its stem/root word


1. DATA PREPROCESSING (Cont..)

● Lemmatization: It does the same thing as stemming, converting a word to its root
form but with one difference. For example, the word “caring” would map to ‘care’
and not ‘car’ in case of stemming.
● N-Grams: These are the combination of multiple words used together.
2. Algorithm Development:

● Rule Based System


● Machine learning based system
Components of NLP

NLP is divided into two components.

● Natural Language Understanding

● Natural Language Generation


Natural Language Understanding (NLU):-

● Natural Language Understanding (NLU) helps the machine to


understand and analyze human language by extracting the text from
large data such as keywords, emotions, relations, and semantics, etc.
Let’s see what challenges are faced by a machine-
For Example:-
● He is looking for a match.
What do you understand by the ‘match’ keyword? Does it partner or cricket or football
or anything else?
This is Lexical Ambiguity. It happens when a word has different meanings. Lexical
ambiguity can be resolved by using parts-of-speech (POS)tagging techniques.
● The Fish is ready to eat.
What do you understand by the above example? Is the fish ready to eat his/her food or
fish is ready for someone to eat? Got confused!! Right? We will see it practically below.
This is Syntactical Ambiguity which means when we see more meanings in a sequence
of words
Natural Language Generation (NLG): :-

● It is the process of extracting meaningful insights as phrases


and sentences in the form of natural language.
It consists −
● Text planning − It includes retrieving the relevant data from
the domain.
● Sentence planning − It is nothing but a selection of important
words, meaningful phrases, or sentences.
SENTENCE ANALYSIS PHASE

Top 5 Natural Language Processing Phases


● Lexical Analysis.
● Syntactic Analysis.
● Semantic Analysis.
● Discourse Analysis.
● Pragmatic Analysis.
1. Lexical analysis

● It involves identifying and analyzing the structure of words. Lexicon of a


language means the collection of words and phrases in that particular language.
● The lexical analysis divides the text into paragraphs, sentences, and words. So
we need to perform Lexicon Normalization.
The most common lexicon normalization techniques are Stemming:
● Stemming: Stemming is the process of reducing derived words to their word
stem, base, or root form
● Lemmatization: Lemmatization is the process of reducing a group of words into
their lemma or dictionary form. It takes into account things like POS, the
meaning of the word in the sentence, the meaning of the word in the nearby
sentences, etc. before reducing the word to its lemma.
2. Syntactic analysis

● Syntactic Analysis is used to check grammar, arrangements of words, and


the interrelationship between the words.
Example:
Mumbai goes to the Sara
Here “Mumbai goes to Sara”, which does not make any sense, so this sentence
is rejected by the Syntactic analyzer.
Syntactical parsing involves the analysis of words in the sentence for grammar.
Dependency Grammar and Part of Speech (POS)tags are the important
attributes of text syntactic.
3. Semantic Analysis

● Semantic analysis concerned with the meaning representations


● It is mainly focuses on the literal meaning of words, phrases
and sentences
● Consider the sentence: “ The apple ate a banana”. Although
the sentence is syntactically correct
● It doesn’t make any sense because apples can’t eat.
4. Discourse Integration

● In this phase, the impact of the sentences before a particular


sentence and the effect of the current sentence on the upcoming
sentences is determined.
● It deals with the effect of a previous sentence on the sentence in
consideration
● In the text, “ Jack is bright student. He spends most of the time in
the library”.
● Here discourse assigns “he” to refer to “Jack”.
5. Pragmatic Analysis

● It is a last phase of NLP


● It helps you to discover the intended effect by applying a set
of rules that characterize cooperative dialogues.
● For example: “Open the door” is interpreted as a request
instead of an order.
TYPES OF PARSES

● A parser in NLP uses the grammar rules to verify if the input text is valid or not
syntactically.
● The parser helps us to get the meaning of the provided text (like the dictionary
meaning of provided text).
● As the parser helps us to analyze the syntax error in the text; so the parsing process
is also known as the syntax analysis or the Syntactic analysis.
Types of Parsers
TOP-DOWN PARSING:

● It is the process of construction the parse tree starting at the root and proceeds
towards the leaves.
● In top down parsing words of the sentence are replaced by their categories
like verb phrase (VP), Noun phrase (NP), Preposition phrase (PP), Pronoun
(PRO) etc.
TOP-DOWN PARSING (cont..)

● Recursive Descent Parsing:


a. This technique follows the process for every terminal and non-
terminal entity.
b. It reads the input from left to right and constructs the parse tree from
right to left.
c. As the technique works recursively, it is called recursive descent
parsing.
● Back-tracking: The parsing technique that starts from the initial pointer,
the root node. If the derivation fails, then it restarts the process with
different rules.
Example

Let us consider a sentence “Rahul is eating an apple”


Symbolic representation: Rahul - Noun
S -> NP VP Is - Auxiliary word
Eating - verb
-> N VP [NP = N] An - article
-> N AUX VP [VP Apple
= AUX VP]
- Noun
-> N AUX V NP [VP = V NP]
-> N AUX V ART N [NP = ART N]
NP = NOUN PHRASE
-> Rahul AUX V ART N AUX = AUXILIARY
-> Rahul is V ART N VP = VERB PHRASE
V = VERB
-> Rahul is eating ART N ART= ARTICLE
-> Rahul is eating an N N = NOUN
-> Rahul is eating an apple
Example
BOTTOM-UP PARSING:

● In this parsing technique the process begins with the sentence and the words of
the sentence is replaced by their relevant symbols.
● In bottom up parsing the construction of parse tree starts at the leaves and
proceeds towards the root.
BOTTOM-UP PARSING:

● Shift-Reduce Parsing: Shift-reduce parsing works on two steps: Shift


step and Reduce step.
● Shift step: The shift step indicates the increment of the input pointer
to the next input symbol that is shifted.
● Reduce Step: When the parser has a complete grammar rule on the
right-hand side and replaces it with RHS.
● LR Parsing: It is a syntax analysis techniques as it works with context-
free grammar. In LR parsing L stands for the left to right tracing, and R
stands for the right to left tracing.
Example
SEMANTIC ANALYSIS:

● Semantic analysis is the process of drawing meaning from text.


● It allows computers to understand and interpret sentences, paragraphs, or
whole documents, by analyzing their grammatical structure, and
identifying relationships between individual words in a particular
context.
● Semantic analysis-driven tools can help companies automatically extract
meaningful information from unstructured data, such as emails, support
tickets, and customer feedback.
Elements of Semantic Analysis

1. Hyponymy: It represents the relationship between a generic term (word) and


instances of that generic term. Here the generic term is known as hypernym and
its instances are called hyponyms.
● For example: The word color is hypernym, and the colors blue, yellow,
green, etc. are hyponyms
1. Homonymy: It may be defined as the words having the same spelling or same
form but having different and unrelated meanings.
Example: The word “Bat” is a homonymy word because a bat can be an
implement in two ways: 1. To hit a ball. 2. Bat is a flying mammal also.
Elements of Semantic Analysis (cont..)

3. Polysemy: Polysemy is a Greek word, that means “many signs”. It is a word or phrase with a
different but related sense. In other words, we can say that polysemy has the same spelling but
different and related meanings.
● For Example: The word "Bank" is a Polysemy word. The word “Bank” is a polysemy word
having the following meanings: “A financial institution”.”The building in which such an
institution is located”. “A synonym for “to rely on” “.
4. Synonymy: It represents the relation between two lexical items of different forms but expressing
the same or a close meaning.
● For Example: ‘author/writer’, ‘fate/destiny
5. Antonymy: It is the relation between two lexical items having symmetry between their semantic
components relative to an axis.
For Examples: ‘life/death’, ‘certitude/incertitude”, ‘rich/poor’, ‘hot/cold’, ‘father/son’, ‘moon/sun’.
Meaning Representation
The semantic analysis creates a representation of the meaning of a sentence. Firstly we have
to understand the building blocks of the semantic system.
Building Blocks of Semantic System
● Entities : It represents the individual such as a particular organization, location, people’s
name, etc.
For Example: Punjab, China, Chirag, Kshitiz all are entities.
● Concepts: It represents the general category of the individuals such as a person, city, etc.
● Relations: It represents the relationship between entities and concepts.
For Example: Sentence: Ram is a person
● Predicates: It represents the verb structures.
For Example: Semantic roles and Case Grammar
Techniques of Semantic Analysis

Depending on the type of information you’d like to obtain from data, you
can use one of two semantic analysis techniques
● Semantic classification model:
a. Topic classification: It is a method for processing any text and
sorting them according to different known predefined categories on
the basis of its content.
b. sentiment analysis:It is a method for detecting the hidden sentiment
inside a text, may it be positive, negative or neural
c. Intent classification: It is a method of differentiating any text on the
basis of the intent of your customers. The customers might be
interested or disinterested in your company or services
Techniques of Semantic Analysis

● Semantic extraction models:


a. Keyword Extraction: It is a method of extracting the relevant words and
expressions in any text to find out the granular insights. It is used to analyze different
keywords in a corpus of text and detect which words are ‘negative’ and which words
are ‘positive’.
b. Entity extraction: Any sentence or phrase is made up of different entities like names
of people, places, companies, positions, etc. This method is used to identify those
entities and extract them. It can be very useful for customer service teams of
businesses like delivery companies as the machine can automatically extract the
names of their customers, their location, shipping numbers, contact information or
any other relevant or important data.
Applications of NLP
Expert systems
Introduction to Expert Systems

● Expert System is an interactive and reliable computer-based decision-making


system which uses both facts and heuristics to solve complex decision-making
problems.
● The purpose of an expert system is to solve the most complex issues in a specific
domain.
● The expert system is a part of AI, and the first ES was developed in the year 1970,
which was the first successful approach of artificial intelligence.
● The performance of an expert system is based on the expert's knowledge stored in
its knowledge base.
● The more knowledge stored in the KB, the more that system improves its
performance. One of the common examples of an ES is a suggestion of spelling
errors while typing in the Google search box.
Examples of Expert Systems

MYCIN: It was based on backward chaining and could identify various


bacteria that could cause acute infections. It could also recommend drugs
based on the patient’s weight.
DENDRAL: Expert system used for chemical analysis to predict
molecular structure.
PXDES: An Example of Expert System used to predict the degree and
type of lung cancer
CaDet: One of the best Expert System Example that can identify cancer
at early stage
Characteristics of Expert systems

1. The Highest Level of


Expertise
2. Right on Time Reaction
3. Good Reliability
4. Flexible
5. Effective Mechanism
6. Capable of handling
challenging decision &
problems
Phases of building Expert System

Step 1: Identification
Step 2: Conceptualization
Step 3: Formalization
Step 4: Implementation
Step 5: Testing
Step 1 - Identification

● Determining the characteristics of the problem


Step2: Conceptualization

● Finding the concept to produce the solution.


Step3: Formalization

● Designing structures to organize the knowledge.


Step4: Implementation

● Formulating rules which embody the knowledge


Step5: Testing
● Validating the rules.
● Testing provides an opportunity to identify the weaknesses in the structure and the
implementation of the system.
● Testing includes are:
○ The system implements correctly or incorrectly.
○ Rules implement correctly or not.
○ An Expert System is finally tested to be successful only when it is operated at
the level of a human expert.
○ The testing process is NOT complete until it indicates that the solutions
suggested by the expert system are consistently valid.
○ Expert systems are typically interactive, they work in question-and-answer
form.
○ This interaction between users and the Experts system continues until the system
can conclude.
Expert System Architecture
Expert System Architecture

● Knowledge Base – It is warehouse of special heuristics or rules, which are used directly
by knowledge, facts (productions). It has knowledge that is needed for understanding,
formulating, & problem solving.
● Working Memory – It helps to describe the current running problem and record
intermediate output. Records Intermediate Hypothesis & Decisions: 1. Plan, 2. Agenda,
3. Solution
● Inference Engine – It is heart of expert system as well as helps to manage entire
structure of expert system, and it delivers to different methodology for reasoning.
● Explanation System – It helps to trace responsibility and justify the behavior of expert
system by firing questions and answers, such as Why, How, What, Where, When, Who.
● User Interface – It allows users to insert their queries with using own Natural
Language Processing otherwise menus & graphics.
Expert System Architecture

● Knowledge Engineer – Main objective of this engineer is to design


system for specific problem domain with using of expert system shell.
● System Engineer – To design user interface and declarative format of
knowledge base as well as to build inference engine
● Users – They are non expert person who want to seek direct advice.
● Expert System Shell: shell contains the special software development
environment, and it has basic components of expert system such as –
Knowledge-based management system, Workplace, Explanation facility,
Reasoning capacity, Inference engine, user interface.
Components of Expert Systems
Components of Expert Systems

1. User interface: It is an interface that helps a non-expert user to communicate with the
expert system to find a solution.
2. Inference Engine(Rules of Engine):
○ It applies inference rules to the knowledge base to derive a conclusion or deduce new
information. It helps in deriving an error-free solution of queries asked by the user.
○ With the help of an inference engine, the system extracts the knowledge from the
knowledge base.
○ There are two types of inference engine:
a. Deterministic Inference engine: It uses established rules and logical reasoning to
analyze information and draw conclusions, and these conclusions are assumed to
be true because they are based on the known facts and rules provided to the
engine.
b. Probabilistic Inference engine: This type of inference engine contains
uncertainty in conclusions, and based on the probability.
Inference engine uses the below modes to derive the solutions:

○ Forward Chaining:
a. It is a strategy of an expert system to answer the question, “What can happen next?”
b. 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.
c. This strategy is followed for working on conclusion, result, or effect.
d. For example, prediction of share market status as an effect of changes in interest rates.
○ Backward Chaining:
a. With this strategy, an expert system finds out the answer to the question, “Why this
happened?”
b. 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.
c. This strategy is followed for finding out cause or reason.
d. For example, diagnosis of blood cancer in humans.
Components of Expert Systems

3. Knowledge base:

○ The knowledgebase is a type of storage that stores knowledge acquired from the different
experts of the particular domain.
○ The more the knowledge base, the more precise will be the Expert System.
○ It is similar to a database that contains information and rules of a particular domain or
subject.
Components of Knowledge Base

○ Factual Knowledge: The knowledge which is based on facts and accepted by knowledge
engineers comes under factual knowledge.
○ Heuristic Knowledge: This knowledge is based on practice, the ability to guess,
evaluation, and experiences.
Components of Expert Systems

Components of Knowledge Base

○ Factual Knowledge: The knowledge which is based on facts and accepted by knowledge
engineers comes under factual knowledge.
○ Heuristic Knowledge: This knowledge is based on practice, the ability to guess,
evaluation, and experiences.
Knowledge Representation: It is used to formalize the knowledge stored in the knowledge
base using the If-else rules.
Knowledge Acquisitions: It is the process of extracting, organizing, and structuring the domain
knowledge, specifying the rules to acquire the knowledge from various experts, and store that
knowledge into the knowledge base.
Development of Expert System
Here, we will explain the working of an expert system by taking an example of MYCIN ES. Below are
some steps to build an MYCIN:

○ Firstly, ES should be fed with expert knowledge. In the case of MYCIN, human experts
specialized in the medical field of bacterial infection, provide information about the causes,
symptoms, and other knowledge in that domain.
○ The KB of the MYCIN is updated successfully. In order to test it, the doctor provides a new
problem to it. The problem is to identify the presence of the bacteria by inputting the details of a
patient, including the symptoms, current condition, and medical history.
○ The ES will need a questionnaire to be filled by the patient to know the general information about
the patient, such as gender, age, etc.
○ Now the system has collected all the information, so it will find the solution for the problem by
applying if-then rules using the inference engine and using the facts stored within the KB.
○ In the end, it will provide a response to the patient by using the user interface.
Capabilities of an Expert System
○ Advising: It is capable of advising the human being for the query of any domain from the
particular ES.
○ Provide decision-making capabilities: It provides the capability of decision making in
any domain, such as for making any financial decision, decisions in medical science, etc.
○ Demonstrate a device: It is capable of demonstrating any new products such as its
features, specifications, how to use that product, etc.
○ Problem-solving: It has problem-solving capabilities.
○ Explaining a problem: It is also capable of providing a detailed description of an input
problem.
○ Interpreting the input: It is capable of interpreting the input given by the user.
○ Predicting results: It can be used for the prediction of a result.
○ Diagnosis: An ES designed for the medical field is capable of diagnosing a disease
without using multiple components as it already contains various inbuilt medical tools.
Expert Systems vs Traditional Systems

Expert Systems Traditional Systems


Decision Making These are designed to make decisions based on typically rely on pre-programmed rules and
knowledge and expertise algorithms.

Knowledge It use knowledge representation techniques such as uses data structures such as tables, lists, and arrays.
frames, rules, and semantic networks to represent
Representation knowledge,

Learning ability Expert systems can learn from experience and adapt to Do not have this ability and require manual
new situations reprogramming to adapt to new situations.

Human can interact with humans in a more natural way through Rely on forms and menus for interaction.
the use of natural language processing and other
Interactions advanced interfaces,

Complexity Generally more complex than traditional systems due These are typically simpler and more straightforward.
to the need to represent and reason with complex
knowledge

Domain Specificity Expert systems are designed to operate within a traditional systems can be applied to a wide range of
specific domain of knowledge or expertise domains and applications.
Rule Based Expert Systems

● A rule-based system is a system that applies human-made


rules to store, sort and manipulate data.
● Rule-based systems require a set of facts or source of data, and
a set of rules for manipulating that data.
● These rules are sometimes referred to as ‘If statements’ as they
tend to follow the line of ‘IF X happens THEN do Y’
Elements in Rule Based Systems:

1. Set of Facts: These facts are assertions or anything that is


relevant to the beginning state of the system.
2. Set of rules: This set contains all the actions that should be
performed within the scope of a problem and defines how to act
on the assertion set. In the set of rules facts are represented in an
IF-THEN form
3. Termination criteria: This determines whether a solution exists
or not and figures out when the process should be terminated
Structure of Rule based Expert System

Knowledge base Data base

Inference engine

Explanation
Facility

User interface User


Knowledge Base:
● In rule-based expert system, the knowledge is represented as a set of rules. Each rule
specifies a relation, recommendation, directive, strategy or heuristic and has the IF
(condition) THEN (action) structure.
Database:
● It includes a set of facts used to match against the IF (condition) parts of rules stored
in the knowledge base.
Inference engine:
● It carries out the reasoning whereby the expert system reaches a solution.
● It links the rules given in the knowledge base with the facts provided in the database
Explanation facilities:
● It enable the user to ask the expert system how a particular conclusion is reached and
why a specific fact is needed.
User interface:
● The user interface is the means communication between a user seeking a solution to
the problem and an expert system.
Advantages of Rule Based Systems
Disadvantages
Applications of Expert Systems

Medical diagnosis: analyzing patient symptoms, medical history, and test results.
Financial analysis: analyze financial data and provide investment recommendations
based on market trends and risk assessments
Quality control: identify potential quality issues by analyzing data from sensors and
other sources.
Customer service: provide personalized customer service, providing recommendations
Agriculture: provide farmers with recommendations on crop management, pest
control, and other agricultural practices based on weather conditions and soil data.
Transportation: used to optimize transportation routes, reduce fuel consumption, and
improve safety by analyzing traffic patterns and other data
List of Shells and Tools

● CLIPS: A rule-based programming language used to provide a powerful set of tools for knowledge
representation and inference.
● Jess: A rule-based expert system tool that is similar to CLIPS but is based on the Java programming
language.
● Drools: A business rule management system that can be used to build complex rule-based systems for
decision-making.
● Prolog: A logic-based programming language that can be used to build expert systems for a variety of
domains.
● MATLAB: A powerful tool for developing expert systems in the field of engineering and data science.
● Rete algorithm: A pattern matching algorithm that is commonly used in expert systems to perform rule-
based reasoning.
● Neural networks: Artificial neural networks can also be used as a tool for building expert systems,
especially for domains that require pattern recognition
THE END

You might also like