Learn Python

Learn Data Structure & Algorithm

Learn Numpy

Learn Pandas

Learn Matplotlib

Learn Seaborn

Learn Statistics

Learn Math

Learn MATLAB

Learn Machine learning

Learn Github

Learn OpenCV

Introduction

Setup

ANN

Working process ANN

Propagation

Bias parameter

Activation function

Loss function

Overfitting and Underfitting

Optimization function

Chain rule

Minima

Gradient problem

Weight initialization

Dropout

ANN Regression Exercise

ANN Classification Exercise

Hyper parameter tuning

CNN

CNN basics

Convolution

Padding

Pooling

Data argumentation

Flattening

Create Custom Dataset

Binary Classification Exercise

Multiclass Classification Exercise

Transfer learning

Transfer model Basic template

RNN

How RNN works

LSTM

Bidirectional RNN

Sequence to sequence

Attention model

Transformer model

Bag of words

Tokenization & Stop words

Stemming & Lemmatization

TF-IDF

N-Gram

Word embedding

Normalization

Pos tagging

Parser

semantic analysis

Regular expression

Learn MySQL

Learn MongoDB

Learn Web scraping

Learn Excel

Learn Power BI

Learn Tableau

Learn Docker

Learn Hadoop

Working of parser in rnn

What is parser?




The parser is a software component design that takes input(text) and makes a structural representation(text) of the input. Before giving output it checks the sentence grammatically. If the sentence is correct grammatically only then it will give you the output.

Now there can be a question that how it checks grammatically?
It can check because with the text input, we also input grammar. You will get output when your sentence is grammatically correct. If your sentence is not grammatically correct then you will get an error.

Here we get the output in the form of a tree. This tree is called a parse tree.
So we can say that the parser main work is to check the sentence grammatically and if it's correct then create a parse tree.

Understand basic of grammar and parser tree for compiler




Mathematically we can represent grammar in four tuples: N, T, S, P
Here,
1. N = Non-terminal: Nodes present in the middle of the parse tree. In the example blue marked nodes

2. T = Terminal: Leaf nodes are called terminal. In the image brown marked nodes.

3. S = Start symbol: The first node of the tree is called the start node. In the image green marked node.

4. P = Production rule: The production rule is the given grammar to the parser. In the example our given grammar is E-> E+E | E*E | a| b | c

Here our input is a+b*c. So our target is using the grammar we have to make the input sentence. If the sentence is grammatically correct and if we can't make the input sentence then the sentence is not grammatically correct and we know that if the sentence is grammatically correct only then we will get the input text from the output of the parser in the form of the parse tree.

How to do parsing in NLP?

Target sentence is : The little boy ran quickly

< sentence> --> < noun phrase> < verb phrase>
< noun phrase> --> < adjective>< noun phrase> | <adjective>< singular noun>
< verb phrase> --> < singular verb>< adverb>
< adjective> --> a | the | little
< singular noun> --> boy
< singular verb> --> ran
< adverb> --> quickly

what does these upper things mean?
Here our first input is a sentence. From a sentence, we can get two things one is a noun phrase, and other verb phrase
Form noun phrase we can get two things one is an adjective and noun phrase and the other is adjective and singular noun
From verb phrase, we can get two things one is the singular verb and the other is an adverb.
For adjective, we are taking a, the, and little
For singular noun, we are taking boy
For singular verb we are taking ran
For adverb, we are taking quickly

Now see the given image to understand how the sentence will generate using all these things




Let's understand the parse tree from the image:

At first we have a sentence. From the sentence, we can get two things one is noun phrase, and the other verb phrase.

From noun phrase we can get two things one is adjective and noun phrase and the other are adjective and singular noun. In this case at fist, we will go to adjective and noun phrase because to create the sentence we need two adjectives.
From verb phrase we can get two things one is the singular verb and the other is adverb. Now we have one noun phrase left. So from this noun phrase we will get adjective and singular noun.

Now get the words:
In the last of the tree at first, we have adjectives. For adjective, we took there words the, little, a. Among these, here we will take adjective word the. Then we have another adjective. So here we will take little. Then we have a singular noun. For singular noun we took the boy word. So here we will have boy. After this, we have a singular verb. For singular verb, we took the word ran. So here we will have ran. Then we have adverb. For adverb, we took word quickly. So here we will have word quickly.

Now if we join these words together then we will get:
The little boy ran quickly
and, this was our target sentence.
This way parser works.