AI Notes Part-3
AI Notes Part-3
AI Notes Part-3
PARSING PROCESS
Parsing is the term used to describe the process of automatically building syntactic
analysis of a sentence in terms of a given grammar and lexicon. The resulting
syntactic analysis may be used as input to a process of semantic interpretation.
Occasionally, parsing is also used to include both syntactic and semantic analysis.
The parsing process is done by the parser. The parsing performs grouping and
labeling of parts of a sentence in a way that displays their relationships to each other
in a proper way.
The parser is a computer program which accepts the natural language sentence as
input and generates an output structure suitable for analysis. The lexicon is a
dictionary of words where each word contains some syntactic, some semantic and
possibly some pragmatic information. The entry in the lexicon will contain a root
word and its various derivatives. The information in the lexicon is needed to help
determine the function and meanings of the words in a sentence. The basic parsing
technique is shown in figure .
Types of Parsing
2. Bottom up Parsing
Let us discuss about these two parsing techniques and how they will work for input
sentences.
Top down parsing starts with the starting symbol and proceeds towards the goal. We
can say it is the process of construction the parse tree starting at the root and proceeds
towards the leaves. It is a strategy of analyzing unknown data relationships by
hypothesizing general parse tree structures and then considering whether the known
fundamental structures are compatible with the hypothesis. 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. Let
us consider some examples to illustrate top down parsing. We will consider both the
symbolical representation and the graphical representation. We will take the words
of the sentences and reach at the complete sentence. For parsing we will consider
the previous symbols like PP, NP, VP, ART, N, V and so on. Examples of top down
parsing are LL (Left-to-right, left most derivation), recursive descent parser etc.
In this parsing technique the process begins with the sentence and the words of the
sentence is replaced by their relevant symbols. This process was first suggested by
Yngve (1955). It is also called shift reducing parsing. In bottom up parsing the
construction of parse tree starts at the leaves and proceeds towards the root. Bottom
up parsing is a strategy for analyzing unknown data relationships that attempts to
identify the most fundamental units first and then to infer higher order
structures for them. This process occurs in the analysis of both natural languages and
computer languages. It is common for bottom up parsers to take the form of general
parsing engines that can wither parse or generate a parser for a specific programming
language given a specific of its grammar.
ART ADJ N V NP
ART ADJ N VP
ART NP VP
NP VP
Deterministic Parsing
A deterministic parser is one which permits only one choice for each word category.
That means there is only one replacement possibility for every word category. Thus,
each word has a different test conditions. At each stage of parsing always the correct
choice is to be taken. In deterministic parsing back tracking to some previous
positions is not possible. Always the parser has to move forward. Suppose the parser
some form of incorrect choice, then the parser will not proceed forward. This
situation arises when one word satisfies more than one word categories, such as noun
and verb or adjective and verb. The deterministic parsing network is shown in figure.
Non-Deterministic Parsing
The non deterministic parsing allows different arcs to be labeled with the some
test. Thus, they can uniquely make the choice about the next arc to be taken. In non
deterministic parsing, the back tracking procedure can be possible. Suppose at some
extent of point, the parser does not find the correct word, then at that stage it may
backtracks to some of its previous nodes and then start parsing. But the parser has to
guess about the proper constituent and then backtrack if the guess is later proven to
be wrong. So comparative to deterministic parsing, this procedure maybe helpful
for a number of sentences as it can backtrack at any point of state. A non deterministic
parsing network is shown in figure.
The grammar in which each production has exactly one terminal symbol in its left
handΣ,sideV,S,andP at least one symbol at the right hand side is called context free
grammar. A CFG is a four tuple where
Each terminal symbol in a grammar denotes a language. The non terminals are
written in capital letters and terminals are written in small letters. Some properties
of CFG formalism are
Transformational Grammar
These are the grammars in which the sentence can be represented structurally into
two stages. Obtaining different structures from sentences having the same meaning
is undesirable in language understanding systems. Sentences with the same meaning
should always correspond to the same internal knowledge structures. In one stage
the basic structure of the sentence is analyzed to determine the grammatical
constituent parts and in the second stage just the vice versa of the first one. This
reveals the surface structure of the sentence, the way the sentence is used in speech
or in writing. Alternatively, we can also say that application of the transformation
rules can produce a change from passive voice to active voice and vice versa. Let us
see the structure of a sentence as given below.
Both of the above sentences are two different sentences but they have same
meaning. Thus it is an example of a transformational grammar. These grammars
were never widely used in computational models of natural language. The
applications of this grammar are changing of voice (Active to Passive and Passive
to Active) change a question to declarative form etc.
TRANSITION NETWORK
The transition from N1 to N2 will be made if an article is the first input symbol. If
successful, state N2 is entered. The transition from N2 to N3 can be made if a noun
is found next. If successful, state N3 is entered. The transition from N3 to N4 can
be made if an auxiliary is found and so on. Suppose consider a sentence “A boy is
eating a banana”. So if the sent ence is parsed in the above transition network then,
first ‘A’ is an article. So successful transition t o the node N1 to N2. Then boy is a
noun (so N2 to N3), “is” is an auxiliary (N5 to N6) and finally “banana” is a noun
(N 6 to N7) is done successfully. So the above sentence is successfully parsed in
the transition network.
Case grammars use the functional relationships between noun phrases and verbs to
conduct the more deeper case of a sentence. Generally in our English sentences,
the difference between different forms of a sentence is quite negligible. In early
1970’s Fillmore gave some idea about different cases of a English sentence. He
extended the transformational grammars of Chomsky by focusing more on the
semantic aspects of view of a sentence. In case grammars a sentence id defined as
being composed of a preposition P, a modality constituent M, composed of mood,
tense, aspect, negation and so on. Thus we can represent a sentence like
Where P - Set of relationships among verbs and noun phrases i.e. P = (C=Case)
M - Modality constituent
bhgggfdfgdfg
What to Represent:
Following are the kind of knowledge which needs to be represented in AI systems:
o Object: All the facts about objects in our world domain. E.g., Guitars contains
strings, trumpets are brass instruments.
Types of knowledge
Following are the various types of knowledge:
1. Declarative Knowledge:
2. Procedural Knowledge
3. Meta-knowledge:
4. Heuristic knowledge:
o Heuristic knowledge is representing knowledge of some experts in a filed or
subject.
5. Structural knowledge:
Let's suppose if you met some person who is speaking in a language which you don't
know, then how you will able to act on that. The same thing applies to the intelligent
behavior of the agents.
As we can see in below diagram, there is one decision maker which act by sensing the
environment and using knowledge. But if the knowledge part will not present then, it
cannot display intelligent behavior.
AI
knowledge cycle:
An Artificial intelligence system has the following components for displaying intelligent
behavior:
o Perception
o Learning
o Knowledge Representation and Reasoning
o Planning
o Execution
The above diagram is showing how an AI system can interact with the real world and
what components help it to show intelligence. AI system has Perception component by
which it retrieves information from its environment. It can be visual, audio or another
form of sensory input. The learning component is responsible for learning from data
captured by Perception comportment. In the complete cycle, the main components are
knowledge representation and Reasoning. These two components are involved in
showing the intelligence in machine-like humans. These two components are
independent with each other but also coupled together. The planning and execution
depend on analysis of Knowledge representation and reasoning.
Player1 65 23
Player2 58 18
Player3 75 24
2. Inheritable knowledge:
o In the inheritable knowledge approach, all data must be stored into a hierarchy
of classes.
o Every individual frame can represent the collection of attributes and its value.
3. Inferential knowledge:
o Inferential knowledge approach represents knowledge in the form of formal
logics.
man(Marcus)
∀x = man (x)---------- > mortal (x)s
4. Procedural knowledge:
o Procedural knowledge approach uses small programs and codes which describes
how to do specific things, and how to proceed.
o But it is not necessary that we can represent all cases in this approach.
1. 1. Representational Accuracy:
KR system should have the ability to represent all kind of required knowledge.
2. 2. Inferential Adequacy:
KR system should have ability to manipulate the representational structures to
produce new knowledge corresponding to existing structure.
3. 3. Inferential Efficiency:
The ability to direct the inferential knowledge mechanism into the most
productive directions by storing appropriate guides.
1. Logical Representation
3. Frame Representation
4. Production Rules
1. Logical Representation
Logical representation is a language with some concrete rules which deals with
propositions and has no ambiguity in representation. Logical representation means
drawing a conclusion based on various conditions. This representation lays down some
important communication rules. It consists of precisely defined syntax and semantics
which supports the sound inference. Each sentence can be translated into logics using
syntax and semantics.
Syntax:
o Syntaxes are the rules which decide how we can construct legal sentences in the
logic.
Semantics:
o Semantics are the rules by which we can interpret the sentence in the logic.
a. Propositional Logics
b. Predicate logics
Advantages of logical representation:
1. Logical representation enables us to do logical reasoning.
Note: Do not be confused with logical representation and logical reasoning as logical
representation is a representation language and reasoning is a process of thinking logically.
b. Kind-of-relation
Statements:
a. Jerry is a cat.
b. Jerry is a mammal