Syntactically analysis in Artificial Intelligence
Last Updated :
21 Apr, 2022
In this article, we are going to see about syntactically analysing in Artificial Intelligence.
Parsing is the process of studying a string of words in order to determine its phrase structure using grammatical rules. We can start with the S sign and search top-down for a tree with the words as its leaves, or we can start with the words and search bottom up for a tree that ends in an S, as shown in Figure 23.4. Top-down and bottom-up parsing, on the other hand, can be wasteful since they might result in the same amount of effort being used on parts of the search space that lead to dead ends.
Take a look at the following two sentences:
- Have students in the Physics class take the test?
- Have students in the Physics class taken the test?
These phrases have completely distinct parses, despite the fact that they share the first ten words. The first is a command, while the second is a query. A left-to-right parsing algorithm would have to estimate whether the first word is part of a command or a question, and won't know if it's right until the eleventh word, take or taken. If the algorithm is incorrect, it will have to go back to the initial word and re-analyze the entire phrase using the other meaning.
\begin{array}{ll} \hline \text { List of items } & \text { Rule } \\ \hline S & \\ N P V P & S \rightarrow N P V P \\ N P V P \text { Adjective } & V P \rightarrow V P \text { Adjective } \\ N P \text { Verb Adjective } & V P \rightarrow \text { Verb } \\ N P \text { Verb dead } & \text { Adjective } \rightarrow \text { dead } \\ N P \text { is dead } & \text { Verb } \rightarrow \text { is } \\ \text { Article Noun is dead } & \text { NP } \rightarrow \text { Article Noun } \\ \text { Article wumpus is dead } & \text { Noun } \rightarrow \text { wumpus } \\ \text { the wumpus is dead } & \text { Article } \rightarrow \text { the } \end{array}
We can utilize dynamic programming to eliminate this source of inefficiency: every time we examine a substring, save the findings so we don't have to reanalyze them later. For example, after we determine that "the students in the Physics class" is an NP, we may store the information in a data structure called a chart. Chart parsers are algorithms that achieve this. Because we're working with context-free grammar, every term found in one branch of the search space can be used in any other branch. There are many other types of chart parsers; we discuss the CYK method, which is named after its creators, John Cocke, Daniel Younger, and Tadeo Kasami.
It's worth noting that the CYK algorithm necessitates a grammar that contains all rules in one of two very particular formats: lexical rules in the form X \rightarrow \text { word } , and syntactic rules in the form X \rightarrow Y Z . This grammatical type, known as Chomsky Normal Form, may appear to be limited, but it is not: any context-free grammar may be turned into Chomsky Normal Form automatically.
For general context-free grammars, no algorithm can beat the CYK algorithm, though there are faster algorithms for more restricted grammars. Given that a phrase might have an exponential number of parse trees, the method completing in O(n3) time is quite a feat. Consider the sentence
Fall leaves fall and spring leaves spring.
It's unclear since each word (save "and") can be a noun or a verb, and "fall" and "spring" can also be adjectives. (For instance, one interpretation of "Fall departs fall" is "Autumn abandons autumn.") [S [S [NP Fall leaves] fall] and [S [NP Spring leaves] spring] are two of the four parses in \mathcal{E}_{0} .
- [S[S[N P \text { Fall leaves }] \text { fall }] \text { and }[S[N P \text { spring leaves }] \text { spring }]
- \text { [ } S \text { [ } S \text { [NP Fall leaves] fall] and [ } S \text { spring [ } V P \text { leaves spring] ] }
- [S[S \text { Fall }[V P \text { leaves fall }] \text { and }[S[N P \text { spring leaves }] \text { spring }]
- \text { [ } S \text { [ } S \text { Fall [ } V P \text { leaves fall] ] and [ } S \text { spring [ } V P \text { leaves spring] }
We would have 2c possibilities of choosing parses for the subsentences if we had c two-way-ambiguous conjoined subsentences. In O(c3) time, how does the CYK algorithm handle these 2c parse trees? The solution is that it doesn't need to look at all of the parse trees; all it needs to do is compute the probability of the most likely one. The subtrees are all represented in the P table, and we could enumerate them all (in exponential time) with a little effort, but the beauty of the CYK method is that we don't have to.
Similar Reads
Semantic Networks in Artificial Intelligence
Semantic networks are a powerful tool in the field of artificial intelligence (AI), used to represent knowledge and understand relationships between different concepts. They are graphical representations that connect nodes (representing concepts) with edges (representing relationships). Semantic net
9 min read
Artificial Intelligence Tutorial | AI Tutorial
Artificial Intelligence (AI) refers to the simulation of human intelligence in machines that are programmed to think and act like humans. It involves the development of algorithms and computer programs that can perform tasks that typically require human intelligence such as visual perception, speech
7 min read
Turing Test in Artificial Intelligence
The Turing Test is one of the most well-known and debated concepts in artificial intelligence (AI). It was proposed by the British mathematician and computer scientist Alan Turing in 1950 in his seminal paper, "Computing Machinery and Intelligence." He proposed that the "Turing test is used to deter
9 min read
Propositional Logic in Artificial Intelligence
Propositional logic is used for solving complex problems using simple statements. These statements can either be true or false but cannot be both at same time. These propositions form knowledge representation, reasoning and decision-making in AI systems. In this article we will see the basics of pro
7 min read
Artificial Intelligence - Terminology
Artificial Intelligence is a study to make computers, robots, generally, machines think how the intellect of humans works, think, learn when it solves any problem. This will affect software systems that are more intelligent than usual. The main objective of Artificial Intelligence is to enhance comp
2 min read
Types of Reasoning in Artificial Intelligence
In today's tech-driven world, machines are being designed to mimic human intelligence and actions. One key aspect of this is reasoning, a logical process that enables machines to conclude, make predictions, and solve problems just like humans. Artificial Intelligence (AI) employs various types of re
6 min read
Prepositional Inference in Artificial Intelligence
Let's start with quantifiers that are universal. Assume we have in our knowledge base the conventional folklore axiom that All Greedy Kings Are Bad: \forall x \operatorname{King}(x) \wedge \operatorname{Greed} y(x) \Rightarrow \operatorname{Evil}(x) Then it appears that inferring any of the followin
3 min read
Components of Artificial Intelligence (AI)
Artificial Intelligence (AI) helps machines to think, learn and act like humans. Components of AI help systems to mimic human intelligence which allows them to make decisions, solve problems and understand the world around them. In this article, weâll see these components and explain how they help A
5 min read
Artificial Intelligence - Temporal Logic
Introduction: Temporal logic is a subfield of mathematical logic that deals with reasoning about time and the temporal relationships between events. In artificial intelligence, temporal logic is used as a formal language to describe and reason about the temporal behavior of systems and processes. Te
7 min read
Artificial Intelligence | Natural Language Generation
Artificial Intelligence, defined as intelligence exhibited by machines, has many applications in today's society. One of its applications, most widely used is natural language generation. What is Natural Language Generation (NLG)?Natural Language Generation (NLG) simply means producing text from com
10 min read