The CKY algorithm constructs parse trees for sentences by building a triangular table where diagonal elements represent individual words with their grammatical categories, then iteratively combining adjacent cells based on grammar rules to form non-terminal nodes until reaching the root node (S), which represents the complete sentence structure.
CKY Algorithm for CFG: Construct Parse Tree | NLP Numerical Solved
Added:[Music] hello everyone welcome back to my YouTube channel in this particular video we'll be looking into one more frequently Asked numerical from natural language processing so basically this is on the topic CKY algorithm so the question says that for a given grammar using cyk or CKY algorithm we need to pass through this particular stream statement and the statement is the man read this book now for this particular statement there are certain rules that are given these are the grammar rules that is provided in the question now with the help of this particular rule we have to construct the pass tree which will result into this particular statement so without any further delay let's start so the very first thing that you need to do in CK algorithm is to construct a table something like this now basically if you look at the statement in this particular statement we have total five words the man read this book therefore we have to construct a table with the size 5 cross 5 something like this and we are going to only look into the upper right part of this particular table so our main focus will be on these CS so it's very simple to create this particular table we just have created Five cross five size table and we have just eliminated the bottom left part so this is how the table will look like and we just have given each cell the word from the statement so first cell is having the word the the second cell having is having the word man third is Read Fourth this and fifth book similarly L at the rules also we have done the same the first rule is given the number one and the word the similar the second has the word man the third has the word read the fourth has the word this and the fifth has the word book so I hope till this point it is very much clear now the very first thing that we need to fill in this particular entire table is that we just have to fill the diagonal elements first so we have so now just focus on this diagonal part over here if you look at this particular location the location is 1A 1 the word here is the now in the grammar rules we need to look for a rule where the word the is present so over here you can see this particular word comes as a determiner so that is why in place of this particular cell we have to write determiner that is De similarly the next diagonal position is this 2A 2 here the word man comes so we need to look for the rule in which the word man is present so over here you can see the word man is present as a noun it is acting as a noun the rule says that it is a noun so that is why we have to write over here now the next word is read which comes at the location 3 comma 3 read is the word which is present inside the rule verb so over here in this particular rule verb is comprising of the word read so that is why in this particular cell we'll write verb now after this the word comes is this so over here at the location 4 comma 4 the word this comes and if you look at the grammar rules over here the word this comes as a determiner in the rule so again we have to write D in this particular location now after this the fifth word is the book at the location 5 comma 5 so over here you can see book is the word which is coming under two rules the first is in the noun and the second is in the verb so we have to write both this thing noun as well as verb so let's write that so we'll write noun and we'll write verb in this now as I already told you that we need to create a par stream now tree consists of root node it consists of non-leaf node as well as it consists of leaf nodes you can think that this particular diagonal elements are nothing but Leaf nodes now as you know Leaf nodes come together to form non-leaf nodes and non-leaf nodes come together to form root node so you can think this particular position as root node and these as Leaf nodes now we'll try to combine the Leaf nodes into non-leaf nodes and finally we'll combine the non-leaf nodes to uh root node so that we will reach here now over here we'll try to form non-leaf nodes by looking at the rules now we'll check in the grammar rule whether determiner and noun are appearing together let's have a look so over here in the rule determiner is present but with that nominal is present now if again we look for for the rules nominal accounts for noun so indirectly this nominal is pointing to noun so with determiner we can also write noun in place of nominal because nominal is nothing but noun so that is why these two are appearing together and what is the rule NP that is the noun phrase is nothing but determiner with noun so that is why these two Leaf nodes can come together to form a non-leaf node that is NP so I hope how we are trying to combine it is clear to you all we are checking the grammar rules and if these two are appearing together we are combining it now similarly we look for the other ones we'll try for verb and determiner so let's try to check in the grammar rules whether verb and determiner are coming together so here you can see determiner as I already told you that nominal is nothing but noun so that is why determiner and noun are coming together but determiner and verb is not anywhere present so hence these two won't be combined now let's move further let's try to combine these two do you want to check out this attractive funny memes then what are you waiting for these are just a glimpse of the memes that I have created on my Instagram page you can find the link to my Instagram handle in the description box please visit the link and do watch all these interesting funny Mees these are not just means these memes and reals contains technical information here I try to relate memes with the technological Concepts so please do appreciate that by watching all those and if you love it please hit the follow button determiner and noun or determiner and verb we already know that determiner and noun can be combined to form noun phrase as the rulle says you can see determiner nominal nominal is noun so minor noun can comprise together to form noun phrase so we can simply combine these two and we can write noun phrase over here and now we are completed with this particular level let's move a step ahead and try to check whether the further combinations are possible now over here you can see we have NP let's try to check whether NP and verb are appearing together in the grammar rules so in the grammar rule if you see we have this particular rule NP and verb where both this things are appearing together and it is forming VP so according to this particular rule we can simply combine these two verb and NP so let's do that verb and NP it forms verb phrase that is VP now since verb is already done we are done with this particular level now let's try to see what exactly further can be combined now over here we have verb phase and we have noun phrase let's check whether verb phrase and noun pH can be combined whether it is present together in the rule let's see over here you can see in the first very first rule noun phrase and verb phrase are appearing together and the start is actually comprising these two so we can simply combine the ver phrase and noun phrase together and we can simply write this together as s and that's it we have reached our root node so now let's try to construct the pass street so here it start with s and and then it moves to NP that is the noun phrase and VP that is the verb phrase so let's write NP and VP both of them are at the same level now noun phrase is comprising of determiner as well as noun so let's write that now over here if you look in the grammar rules noun is not directly present with determiner with determiner nominal is present so that is why we will have to first write nominal and then we can write noun so we'll have to first write nominal and then we can simply point to noun so let's do that so over here it is nominal then this nominal can point to noun now this part is done now we'll move to VP that is the work pH part so over here inside this particular table here verb phrase is comprising of verb as well as noun phrase so let's do that so let's write verb and noun phrase that is NP and now we know that inside this particular table NP is comprising of determiner and noun determiner was not getting combined with verb so that is why we'll write determiner and and noun as per the rules now as we know noun is not directly accessible so first we'll write nominal and then we can write noun now once we write this we now have to come back to the words here the word the corresponds to the determiner so that is why here we are going to write the similarly next comes noun at the very Leaf node so here you can see at the place 2 comma 2 we have noun which corresponds to the word man so that is why we'll write man and next we have is verb here you can see that verb is at the place 3 comma 3 which corresponds to the word read so that is why here in in this particular location we will be writing read next we have determiner and here you can see that determiner is present at the location 4A 4 here the word this is getting corresponded so that is why we'll write the word this and finally we have noun here you can see at the location size comma 5 we have noun which corresponds to the word book so that is we'll be writing over here book and there we go the man read this book we have successfully got this particular statement that was what asked in the question we have to pass this particular statement and we successfully did that so I hope this particular problem is clear to you all I hope now you have got an idea how we can tackle this particular problem and it ask us to pass this treatement with the help of CQ algorithm I hope everything is clear if you guys have any single doubt then you can straight away put it in the comment section I'll be happy to solve it please share with your friends as much as possible so that they can also get benefit out of this if you like this particular video please do like share and subscribe to my channel also hit the Bell icon and don't forget to follow me on Instagram please join me on Telegram and thanks for watching have a good Daye [Music]
Up Next

PCFG Models for Ambiguity Resolution in NLP Parsing
@GlancEd77
12.2K views•2024-04-30

Building Real-Time ML Pipelines with Feature Stores and MLOps Frameworks
@ODSCAI
5.1K views•2022-02-20

Bypassing Tor Censorship: Bridges and Pluggable Transport Guide
@Coding_ForEveryone
397 views•2024-06-11

Neural Networks Explained: Math, Layers, and Learning Fundamentals
@3blue1brown
21.9M views•2017-10-05
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Artificial Intelligence






































